<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 1.5.7.1">
<title>Flowable DMN 用户手册 (v 6.4.2-SNAPSHOT)</title>
<style>

/* normalize.css */

button,hr,input{overflow:visible}audio,canvas,progress,video{display:inline-block}progress,sub,sup{vertical-align:baseline}html{font-family:sans-serif;line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0} menu,article,aside,details,footer,header,nav,section{display:block}h1{font-size:2em;margin:.67em 0}figcaption,figure,main{display:block}figure{margin:1em 40px}hr{box-sizing:content-box;height:0}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}a{background-color:transparent;-webkit-text-decoration-skip:objects}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}dfn{font-style:italic}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}audio:not([controls]){display:none;height:0}img{border-style:none}svg:not(:root){overflow:hidden}button,input,optgroup,select,textarea{font-family:sans-serif;font-size:100%;line-height:1.15;margin:0}button,input{}button,select{text-transform:none}[type=submit], [type=reset],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:ButtonText dotted 1px}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}[hidden],template{display:none}/*# sourceMappingURL=normalize.min.css.map */

/* tocbot 2.1.4 */

.toc{overflow-y:auto}.toc>ul{overflow:hidden;position:relative}.toc-list{margin:0;padding-left:10px}a.toc-link{color:currentColor;height:100%}.is-collapsible{max-height:1000px;overflow:hidden;transition:all 300ms ease-in-out}.is-collapsed{max-height:0}.is-position-fixed{position:fixed !important;top:0}.is-active-link{font-weight:700}.toc-link::before{background-color:#f9f9fb;content:' ';display:inline-block;height:inherit;left:8px;margin-top:-1px;position:absolute;width:2px}.is-active-link::before{background-color:#54BC4B}


/* Activiti Specific */

body {
  color: #494d55;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  height: 100%;
  width: 100%;
  background: #f9f9f9;
  font-family: "Helvetica Neue",Helvetica,Roboto,Arial,sans-serif;
  color: #484848
}

.page-wrapper {
  min-height: 100%;
  /* equal to footer height */
  margin-bottom: -50px;
}

.page-wrapper:after {
  content: "";
  display: block;
  height: 50px;
}

#header {
  position:fixed;
  top:0px;
  z-index:100000;
  width:100%;
}

#header > h1 {
    background: #a0cc47;
    color: #f9f9f9;
    border-bottom: 2px solid #042944;
    padding: 20px 0 20px 20px;
    font-size: 40px;
    font-weight: 800;
    line-height: 1.1;
    margin: 0;
}

#header > h1:before {
  background:url('images/logo.png');
  background-size: 337px 54px; background-repeat: no-repeat;
  width: 337px;
  height: 54px;
  display:inline-block;
  content:'';
  margin-right: 30px;
}

#author {
  margin-left: 25%;
  font-size: 40px;
}

#content {
  margin: 129px 0 0 27%;
  padding: 10px 40px 0 20px;
  padding-right: 40px;
  line-height: 1.7;
  width: 65%;
  overflow-x: auto;
}

h2, h3, h4, h5, h6 {
  color: #00345a;
}

h2 {
  font-size: 26px;
  margin-top: 0;
  margin-bottom: 20px;
  font-weight: bold;
  padding-bottom: 10px;
  border-bottom: 1px solid #d7d7d7;
}

h3 {
  font-size: 18px;
  margin-top: 0;
  margin-bottom: 0;
  font-weight: bold;
  padding-bottom: 10px;
  /*border-bottom: 1px solid #d7d7d7;*/
}

h4 {
    font-size: 16px;
    font-weight: bold;
}

h5 {
    font-size: 14px;
    font-weight: bold;
}

h6, h7 {
    font-size: 14px;
    font-weight: bold;
    margin-top: 0;
    margin-bottom: 0;
}

.sect1, .sect2 {
  margin-bottom: 20px;
}

.clear
{
  clear: both;
}

.note, .listingblock, .literalblock{
  padding-left: 8px;
  padding-right: 8px;
  margin-bottom: 14px;
  background-color: #f7f7f9;
  border: 1px solid #e1e1e8;
  border-radius: 4px;
  color: #808080;
}

table.tableblock {
  width: 100%;
  max-width: 100%;
  margin-bottom: 20px;
  background-color: transparent;
  border-spacing: 0;
  border-collapse: collapse;
  border: 1px solid #ddd;
  table-layout: fixed;
}

table.tableblock>caption+thead>tr:first-child>td, table.tableblock>caption+thead>tr:first-child>th, table.tableblock>colgroup+thead>tr:first-child>td, table.tableblock>colgroup+thead>tr:first-child>th, table.tableblock>thead:first-child>tr:first-child>td, table.tableblock>thead:first-child>tr:first-child>th {
    border-top: 0;
}

table.tableblock > thead > tr > th {
    border-bottom-color: #8bd6d8;
}

table.tableblock>thead>tr>th {
    vertical-align: bottom;
    border-bottom: 1px solid #ddd;
}

table.tableblock>tbody>tr>td, table.tableblock>tbody>tr>th, table.tableblock>tfoot>tr>td, table.tableblock>tfoot>tr>th, table.tableblock>thead>tr>td, table.tableblock>thead>tr>th {
    padding: 8px;
    line-height: 1.42857143;
    vertical-align: top;
    border-top: 1px solid #ddd;
}

th {
    text-align: left;
}

table.tableblock > tbody > tr:nth-of-type(odd) {
    background-color: #f5f5f5;
}

table.tableblock > tbody > tr:nth-of-type(odd) {
    background-color: #f9f9f9;
}

td > p {
  margin:0;
}

td.content {
  white-space: normal;
}

pre, td, th {
   white-space: pre-wrap;
   white-space: -moz-pre-wrap;
   white-space: -pre-wrap;
   white-space: -o-pre-wrap;
   word-wrap: break-word;
}

img {
  max-width: 100%;
}

a {
  color: #007387;
}

a:hover {
  color: #004c59;
}

#toc-parent {
  width: 25%;
  float: left;
  height: 100%;
  overflow-y: auto;
  position: fixed;
  padding: 10px;
  border-right: 1px solid #ccc;
}

#generated-toc {
    width: 100%;
    height: 100%;
    font-size: 16px;
}

.toc-link {
  text-decoration: none;
}

.toc-list {
  margin: 0 20px 0 10px;
}

.toc-list-item {
  padding: 4px 0 4px 0;
}


div.sect5  p {
    margin-top: 0;
    margin-bottom: 0;
}

div.sect5  code {
    font-family: "Helvetica Neue",Helvetica,Roboto,Arial,sans-serif;
}
</style>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
.listingblock .pygments .hll { background-color: #ffffcc }
.listingblock .pygments, .listingblock .pygments code { background: #f8f8f8; }
.listingblock .pygments .tok-c { color: #408080; font-style: italic } /* Comment */
.listingblock .pygments .tok-err { border: 1px solid #FF0000 } /* Error */
.listingblock .pygments .tok-k { color: #008000; font-weight: bold } /* Keyword */
.listingblock .pygments .tok-o { color: #666666 } /* Operator */
.listingblock .pygments .tok-ch { color: #408080; font-style: italic } /* Comment.Hashbang */
.listingblock .pygments .tok-cm { color: #408080; font-style: italic } /* Comment.Multiline */
.listingblock .pygments .tok-cp { color: #BC7A00 } /* Comment.Preproc */
.listingblock .pygments .tok-cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */
.listingblock .pygments .tok-c1 { color: #408080; font-style: italic } /* Comment.Single */
.listingblock .pygments .tok-cs { color: #408080; font-style: italic } /* Comment.Special */
.listingblock .pygments .tok-gd { color: #A00000 } /* Generic.Deleted */
.listingblock .pygments .tok-ge { font-style: italic } /* Generic.Emph */
.listingblock .pygments .tok-gr { color: #FF0000 } /* Generic.Error */
.listingblock .pygments .tok-gh { color: #000080; font-weight: bold } /* Generic.Heading */
.listingblock .pygments .tok-gi { color: #00A000 } /* Generic.Inserted */
.listingblock .pygments .tok-go { color: #888888 } /* Generic.Output */
.listingblock .pygments .tok-gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.listingblock .pygments .tok-gs { font-weight: bold } /* Generic.Strong */
.listingblock .pygments .tok-gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.listingblock .pygments .tok-gt { color: #0044DD } /* Generic.Traceback */
.listingblock .pygments .tok-kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.listingblock .pygments .tok-kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.listingblock .pygments .tok-kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.listingblock .pygments .tok-kp { color: #008000 } /* Keyword.Pseudo */
.listingblock .pygments .tok-kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.listingblock .pygments .tok-kt { color: #B00040 } /* Keyword.Type */
.listingblock .pygments .tok-m { color: #666666 } /* Literal.Number */
.listingblock .pygments .tok-s { color: #BA2121 } /* Literal.String */
.listingblock .pygments .tok-na { color: #7D9029 } /* Name.Attribute */
.listingblock .pygments .tok-nb { color: #008000 } /* Name.Builtin */
.listingblock .pygments .tok-nc { color: #0000FF; font-weight: bold } /* Name.Class */
.listingblock .pygments .tok-no { color: #880000 } /* Name.Constant */
.listingblock .pygments .tok-nd { color: #AA22FF } /* Name.Decorator */
.listingblock .pygments .tok-ni { color: #999999; font-weight: bold } /* Name.Entity */
.listingblock .pygments .tok-ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.listingblock .pygments .tok-nf { color: #0000FF } /* Name.Function */
.listingblock .pygments .tok-nl { color: #A0A000 } /* Name.Label */
.listingblock .pygments .tok-nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.listingblock .pygments .tok-nt { color: #008000; font-weight: bold } /* Name.Tag */
.listingblock .pygments .tok-nv { color: #19177C } /* Name.Variable */
.listingblock .pygments .tok-ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.listingblock .pygments .tok-w { color: #bbbbbb } /* Text.Whitespace */
.listingblock .pygments .tok-mb { color: #666666 } /* Literal.Number.Bin */
.listingblock .pygments .tok-mf { color: #666666 } /* Literal.Number.Float */
.listingblock .pygments .tok-mh { color: #666666 } /* Literal.Number.Hex */
.listingblock .pygments .tok-mi { color: #666666 } /* Literal.Number.Integer */
.listingblock .pygments .tok-mo { color: #666666 } /* Literal.Number.Oct */
.listingblock .pygments .tok-sa { color: #BA2121 } /* Literal.String.Affix */
.listingblock .pygments .tok-sb { color: #BA2121 } /* Literal.String.Backtick */
.listingblock .pygments .tok-sc { color: #BA2121 } /* Literal.String.Char */
.listingblock .pygments .tok-dl { color: #BA2121 } /* Literal.String.Delimiter */
.listingblock .pygments .tok-sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.listingblock .pygments .tok-s2 { color: #BA2121 } /* Literal.String.Double */
.listingblock .pygments .tok-se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.listingblock .pygments .tok-sh { color: #BA2121 } /* Literal.String.Heredoc */
.listingblock .pygments .tok-si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.listingblock .pygments .tok-sx { color: #008000 } /* Literal.String.Other */
.listingblock .pygments .tok-sr { color: #BB6688 } /* Literal.String.Regex */
.listingblock .pygments .tok-s1 { color: #BA2121 } /* Literal.String.Single */
.listingblock .pygments .tok-ss { color: #19177C } /* Literal.String.Symbol */
.listingblock .pygments .tok-bp { color: #008000 } /* Name.Builtin.Pseudo */
.listingblock .pygments .tok-fm { color: #0000FF } /* Name.Function.Magic */
.listingblock .pygments .tok-vc { color: #19177C } /* Name.Variable.Class */
.listingblock .pygments .tok-vg { color: #19177C } /* Name.Variable.Global */
.listingblock .pygments .tok-vi { color: #19177C } /* Name.Variable.Instance */
.listingblock .pygments .tok-vm { color: #19177C } /* Name.Variable.Magic */
.listingblock .pygments .tok-il { color: #666666 } /* Literal.Number.Integer.Long */
</style>
<script type="text/javascript">

/*
 * Tocbot.min.js version 2.1.4
 */

 !function(e){function t(o){if(n[o])return n[o].exports;var i=n[o]={exports:{},id:o,loaded:!1};return e[o].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([/*!*************************!*\
   !*** ./src/js/index.js ***!
   \*************************/
 function(e,t,n){var o,i,r;(function(l){!function(n,l){i=[],o=l(n),r="function"==typeof o?o.apply(t,i):o,!(void 0!==r&&(e.exports=r))}("undefined"!=typeof l?l:this.window||this.global,function(e){"use strict";function t(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var o in n)h.call(n,o)&&(e[o]=n[o])}return e}function o(e,t,n){t||(t=250);var o,i;return function(){var r=n||this,l=+new Date,s=arguments;o&&l<o+t?(clearTimeout(i),i=setTimeout(function(){o=l,e.apply(r,s)},t)):(o=l,e.apply(r,s))}}var i,r,l,s=n(/*! smooth-scroll */1),c=n(/*! ./default-options.js */2),a={},u={},d=n(/*! ./build-html.js */3),f=n(/*! ./parse-content.js */4),m=(e.document,document.body,!!e.document.querySelector&&!!e.addEventListener),h=Object.prototype.hasOwnProperty;return u.destroy=function(){try{document.querySelector(a.tocSelector).innerHTML=""}catch(e){console.warn("Element not found: "+a.tocSelector)}document.removeEventListener("scroll",this._scrollListener,!1),document.removeEventListener("resize",this._scrollListener,!1),i&&document.removeEventListener("click",this._clickListener,!1),s&&s.destroy()},u.init=function(e){if(m&&(a=t(c,e||{}),this.options=a,this.state={},i=d(a),r=f(a),this._buildHtml=i,this._parseContent=r,u.destroy(),l=r.selectHeadings(a.contentSelector,a.headingSelector),null!==l)){var n=r.nestHeadingsArray(l),h=n.nest;return i.render(a.tocSelector,h),this._scrollListener=o(function(){i.updateToc(l)},a.throttleTimeout),this._scrollListener(),document.addEventListener("scroll",this._scrollListener,!1),document.addEventListener("resize",this._scrollListener,!1),this._clickListener=o(function(e){i.disableTocAnimation(e),i.updateToc(l)},a.throttleTimeout),document.addEventListener("click",this._clickListener,!1),s&&(this.smoothScroll=s.init(t(a.smoothScrollOptions,{callback:i.enableTocAnimation}))),this}},u.refresh=function(e){u.destroy(),u.init(e||this.options)},e.tocbot=u,u})}).call(t,function(){return this}())},/*!******************************************************!*\
   !*** ./~/smooth-scroll/dist/js/smooth-scroll.min.js ***!
   \******************************************************/
 function(e,t,n){var o,i,r;(function(n){/*! smooth-scroll v10.0.1 | (c) 2016 Chris Ferdinandi | MIT License | http://github.com/cferdinandi/smooth-scroll */
 !function(n,l){i=[],o=l(n),r="function"==typeof o?o.apply(t,i):o,!(void 0!==r&&(e.exports=r))}("undefined"!=typeof n?n:this.window||this.global,function(e){"use strict";var t,n,o,i,r,l,s,c={},a="querySelector"in document&&"addEventListener"in e,u={selector:"[data-scroll]",selectorHeader:null,speed:500,easing:"easeInOutCubic",offset:0,callback:function(){}},d=function(){var e={},t=!1,n=0,o=arguments.length;"[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(t=arguments[0],n++);for(var i=function(n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t&&"[object Object]"===Object.prototype.toString.call(n[o])?e[o]=d(!0,e[o],n[o]):e[o]=n[o])};o>n;n++){var r=arguments[n];i(r)}return e},f=function(e){return Math.max(e.scrollHeight,e.offsetHeight,e.clientHeight)},m=function(e,t){var n,o,i=t.charAt(0),r="classList"in document.documentElement;for("["===i&&(t=t.substr(1,t.length-2),n=t.split("="),n.length>1&&(o=!0,n[1]=n[1].replace(/"/g,"").replace(/'/g,"")));e&&e!==document&&1===e.nodeType;e=e.parentNode){if("."===i)if(r){if(e.classList.contains(t.substr(1)))return e}else if(new RegExp("(^|\\s)"+t.substr(1)+"(\\s|$)").test(e.className))return e;if("#"===i&&e.id===t.substr(1))return e;if("["===i&&e.hasAttribute(n[0])){if(!o)return e;if(e.getAttribute(n[0])===n[1])return e}if(e.tagName.toLowerCase()===t)return e}return null},h=function(e){"#"===e.charAt(0)&&(e=e.substr(1));for(var t,n=String(e),o=n.length,i=-1,r="",l=n.charCodeAt(0);++i<o;){if(t=n.charCodeAt(i),0===t)throw new InvalidCharacterError("Invalid character: the input contains U+0000.");r+=t>=1&&31>=t||127==t||0===i&&t>=48&&57>=t||1===i&&t>=48&&57>=t&&45===l?"\\"+t.toString(16)+" ":t>=128||45===t||95===t||t>=48&&57>=t||t>=65&&90>=t||t>=97&&122>=t?n.charAt(i):"\\"+n.charAt(i)}return"#"+r},p=function(e,t){var n;return"easeInQuad"===e&&(n=t*t),"easeOutQuad"===e&&(n=t*(2-t)),"easeInOutQuad"===e&&(n=.5>t?2*t*t:-1+(4-2*t)*t),"easeInCubic"===e&&(n=t*t*t),"easeOutCubic"===e&&(n=--t*t*t+1),"easeInOutCubic"===e&&(n=.5>t?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1),"easeInQuart"===e&&(n=t*t*t*t),"easeOutQuart"===e&&(n=1- --t*t*t*t),"easeInOutQuart"===e&&(n=.5>t?8*t*t*t*t:1-8*--t*t*t*t),"easeInQuint"===e&&(n=t*t*t*t*t),"easeOutQuint"===e&&(n=1+--t*t*t*t*t),"easeInOutQuint"===e&&(n=.5>t?16*t*t*t*t*t:1+16*--t*t*t*t*t),n||t},v=function(e,t,n){var o=0;if(e.offsetParent)do o+=e.offsetTop,e=e.offsetParent;while(e);return o=Math.max(o-t-n,0),Math.min(o,b()-g())},g=function(){return Math.max(document.documentElement.clientHeight,e.innerHeight||0)},b=function(){return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight)},C=function(e){return e&&"object"==typeof JSON&&"function"==typeof JSON.parse?JSON.parse(e):{}},S=function(e){return e?f(e)+e.offsetTop:0},y=function(t,n,o){o||(t.focus(),document.activeElement.id!==t.id&&(t.setAttribute("tabindex","-1"),t.focus(),t.style.outline="none"),e.scrollTo(0,n))};c.animateScroll=function(n,o,l){var c=C(o?o.getAttribute("data-options"):null),a=d(t||u,l||{},c),f="[object Number]"===Object.prototype.toString.call(n),m=f||!n.tagName?null:n;if(f||m){var h=e.pageYOffset;a.selectorHeader&&!i&&(i=document.querySelector(a.selectorHeader)),r||(r=S(i));var g,x,N=f?n:v(m,r,parseInt(a.offset,10)),L=N-h,O=b(),E=0,A=function(t,i,r){var l=e.pageYOffset;(t==i||l==i||e.innerHeight+l>=O)&&(clearInterval(r),y(n,i,f),a.callback(n,o))},H=function(){E+=16,g=E/parseInt(a.speed,10),g=g>1?1:g,x=h+L*p(a.easing,g),e.scrollTo(0,Math.floor(x)),A(x,N,s)},T=function(){clearInterval(s),s=setInterval(H,16)};0===e.pageYOffset&&e.scrollTo(0,0),T()}};var x=function(t){e.location.hash,n&&(n.id=n.getAttribute("data-scroll-id"),c.animateScroll(n,o),n=null,o=null)},N=function(i){if(0===i.button&&!i.metaKey&&!i.ctrlKey&&(o=m(i.target,t.selector),o&&"a"===o.tagName.toLowerCase()&&o.hostname===e.location.hostname&&o.pathname===e.location.pathname&&/#/.test(o.href))){var r=h(o.hash);if("#"===r){i.preventDefault(),n=document.body;var l=n.id?n.id:"smooth-scroll-top";return n.setAttribute("data-scroll-id",l),n.id="",void(e.location.hash.substring(1)===l?x():e.location.hash=l)}n=document.querySelector(r),n&&(n.setAttribute("data-scroll-id",n.id),n.id="",o.hash===e.location.hash&&(i.preventDefault(),x()))}},L=function(e){l||(l=setTimeout(function(){l=null,r=S(i)},66))};return c.destroy=function(){t&&(document.removeEventListener("click",N,!1),e.removeEventListener("resize",L,!1),t=null,n=null,o=null,i=null,r=null,l=null,s=null)},c.init=function(n){a&&(c.destroy(),t=d(u,n||{}),i=t.selectorHeader?document.querySelector(t.selectorHeader):null,r=S(i),document.addEventListener("click",N,!1),e.addEventListener("hashchange",x,!1),i&&e.addEventListener("resize",L,!1))},c})}).call(t,function(){return this}())},/*!***********************************!*\
   !*** ./src/js/default-options.js ***!
   \***********************************/
 function(e,t){e.exports={tocSelector:".js-toc",contentSelector:".js-toc-content",headingSelector:"h1, h2, h3",ignoreSelector:".js-toc-ignore",linkClass:"toc-link",extraLinkClasses:"",activeLinkClass:"is-active-link",listClass:"toc-list",extraListClasses:"",isCollapsedClass:"is-collapsed",collapsibleClass:"is-collapsible",listItemClass:"toc-list-item",collapseDepth:0,smoothScrollOptions:{easing:"easeInOutCubic",offset:0,speed:300,updateURL:!0},headingsOffset:0,throttleTimeout:50,positionFixedSelector:null,positionFixedClass:"is-position-fixed",fixedSidebarOffset:"auto",includeHtml:!1}},/*!******************************!*\
   !*** ./src/js/build-html.js ***!
   \******************************/
 function(e,t){e.exports=function(e){function t(e,n){var r=n.appendChild(o(e));if(e.children.length){var l=i(e.isCollapsed);e.children.forEach(function(e){t(e,l)}),r.appendChild(l)}}function n(e,n){var o=!1,r=i(o);n.forEach(function(e){t(e,r)});var l=document.querySelector(e);if(null!==l)return l.firstChild&&l.removeChild(l.firstChild),l.appendChild(r)}function o(t){var n=document.createElement("li"),o=document.createElement("a");return e.listItemClass&&n.setAttribute("class",e.listItemClass),e.includeHtml&&t.childNodes.length?u.call(t.childNodes,function(e){o.appendChild(e.cloneNode(!0))}):o.textContent=t.textContent,o.setAttribute("data-scroll",""),o.setAttribute("href","#"+t.id),o.setAttribute("class",e.linkClass+h+"node-name--"+t.nodeName+h+e.extraLinkClasses),n.appendChild(o),n}function i(t){var n=document.createElement("ul"),o=e.listClass+h+e.extraListClasses;return t&&(o+=h+e.collapsibleClass,o+=h+e.isCollapsedClass),n.setAttribute("class",o),n}function r(){var t=document.documentElement.scrollTop||f.scrollTop,n=document.querySelector(e.positionFixedSelector);"auto"===e.fixedSidebarOffset&&(e.fixedSidebarOffset=document.querySelector(e.tocSelector).offsetTop),t>e.fixedSidebarOffset?n.className.indexOf(e.positionFixedClass)===-1&&(n.className+=h+e.positionFixedClass):n.className=n.className.split(h+e.positionFixedClass).join("")}function l(t){var n=document.documentElement.scrollTop||f.scrollTop;e.positionFixedSelector&&r();var o,i=t;if(m&&null!==document.querySelector(e.tocSelector)&&i.length>0){d.call(i,function(t,r){if(t.offsetTop>n+e.headingsOffset){var l=0===r?r:r-1;return o=i[l],!0}if(r===i.length-1)return o=i[i.length-1],!0});var l=document.querySelector(e.tocSelector).querySelectorAll("."+e.linkClass);u.call(l,function(t){t.className=t.className.split(h+e.activeLinkClass).join("")});var c=document.querySelector(e.tocSelector).querySelector("."+e.linkClass+".node-name--"+o.nodeName+'[href="#'+o.id+'"]');c.className+=h+e.activeLinkClass;var a=document.querySelector(e.tocSelector).querySelectorAll("."+e.listClass+"."+e.collapsibleClass);u.call(a,function(t){var n=h+e.isCollapsedClass;t.className.indexOf(n)===-1&&(t.className+=h+e.isCollapsedClass)}),c.nextSibling&&(c.nextSibling.className=c.nextSibling.className.split(h+e.isCollapsedClass).join("")),s(c.parentNode.parentNode)}}function s(t){return t.className.indexOf(e.collapsibleClass)!==-1?(t.className=t.className.split(h+e.isCollapsedClass).join(""),s(t.parentNode.parentNode)):t}function c(t){var n=t.target||t.srcElement;n.className.indexOf(e.linkClass)!==-1&&(m=!1)}function a(){m=!0}var u=[].forEach,d=[].some,f=document.body,m=!0,h=" ";return{enableTocAnimation:a,disableTocAnimation:c,render:n,updateToc:l}}},/*!*********************************!*\
   !*** ./src/js/parse-content.js ***!
   \*********************************/
 function(e,t){e.exports=function(e){function t(e){return e[e.length-1]}function n(e){return+e.nodeName.split("H").join("")}function o(t){var o={id:t.id,children:[],nodeName:t.nodeName,headingLevel:n(t),textContent:t.textContent.trim()};return e.includeHtml&&(o.childNodes=t.childNodes),o}function i(i,r){for(var l=o(i),s=n(i),c=r,a=t(c),u=a?a.headingLevel:0,d=s-u;d>0;)a=t(c),a&&void 0!==a.children&&(c=a.children),d--;return s>=e.collapseDepth&&(l.isCollapsed=!0),c.push(l),c}function r(t,n){var o=n;e.ignoreSelector&&(o=n.split(",").map(function(t){return t.trim()+":not("+e.ignoreSelector+")"}));try{return document.querySelector(t).querySelectorAll(o)}catch(i){return console.warn("Element not found: "+t),null}}function l(e){return s.call(e,function(e,t){var n=o(t);return i(n,e.nest),e},{nest:[]})}var s=[].reduce;return{nestHeadingsArray:l,selectHeadings:r}}}]);
 //# sourceMappingURL=tocbot.min.js.map

</script>

<script type="text/javascript">

  var generateToc = function() {
    var readyState = document.readyState;
    if (readyState === 'interactive' || readyState == 'complete') {

      var headerSize = 140;

      var tocParentNode = document.createElement("div");
      tocParentNode.setAttribute("id", "toc-parent");

      var generatedTocNode = document.createElement("div");
      generatedTocNode.setAttribute("id", "generated-toc");
      tocParentNode.appendChild(generatedTocNode);

      var contentNode = document.getElementById("content");
      contentNode.parentNode.insertBefore(tocParentNode, contentNode);

      var clearNode = document.createElement("div");
      clearNode.setAttribute("class", "clear");
      contentNode.parentNode.appendChild(clearNode);

      tocbot.init({
        tocSelector: '#generated-toc',
        contentSelector: '#content',
        headingSelector: 'h2, h3, h4, h5',
        headingsOffset: headerSize,
        smoothScrollOptions: {
          easing: 'easeInOutCubic',
          offset: headerSize,
          speed: 300, // animation duration.
          updateURL: true
        },
        collapseDepth: 0
      });

    } else {
      window.setTimeout(function(){
        generateToc();
      }, 50);
    }

  }
  generateToc();

</script>
</head>
<body class="book">
<div id="header">
<h1>Flowable DMN 用户手册 (v 6.4.2-SNAPSHOT)</h1>
</div>
<div id="content">
<div class="sect1">
<h2 id="_introduction">1. Introduction</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="license">1.1. 翻译(说明)</h3>
<div class="paragraph">
<p>由[分享牛Flowable中国社区] 翻译，任何意见建议,欢迎联系QQ:3152981878。
如果想一起成为开源代码贡献人员，欢迎大家加入qq交流群为社区贡献添砖加瓦。qq贡献群：1023773998</p>
</div>
</div>
<div class="sect2">
<h3 id="_协议">1.2. 协议</h3>
<div class="paragraph">
<p>Flowable在<a href="http://www.apache.org/licenses/LICENSE-2.0.html">Apache V2 协议</a>下发布。</p>
</div>
</div>
<div class="sect2">
<h3 id="download">1.3. 下载</h3>
<div class="paragraph">
<p><a href="http://www.flowable.org/downloads.html"><a href="http://www.flowable.org/downloads.html" class="bare">http://www.flowable.org/downloads.html</a></a></p>
</div>
</div>
<div class="sect2">
<h3 id="sources">1.4. 源码</h3>
<div class="paragraph">
<p>Flowable的发布包里包含了大部分源码，以JAR文件方式提供。Flowable的源码也可以通过以下链接获得：
  <a href="https://github.com/flowable/flowable-engine"><a href="https://github.com/flowable/flowable-engine" class="bare">https://github.com/flowable/flowable-engine</a></a></p>
</div>
</div>
<div class="sect2">
<h3 id="required.software">1.5. 必要的软件</h3>
<div class="sect3">
<h4 id="_jdk_8">1.5.1. JDK 8+</h4>
<div class="paragraph">
<p>运行Flowable需要JDK 8或以上版本。可以访问 <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">Oracle Java SE downloads页面</a> 点击“Download JDK”按钮获取。该页面上也有安装指导。安装完成后，可以执行 <code>java -version</code> 。能看到JDK的版本信息就说明安装成功了。</p>
</div>
</div>
<div class="sect3">
<h4 id="_ide">1.5.2. IDE</h4>
<div class="paragraph">
<p>可以自行选择用于Flowable开发的IDE。如果想要使用Flowable Designer，则需要Eclipse Mars或Neon。
到 <a href="http://www.eclipse.org/downloads/">Eclipse下载页面</a>选择Eclipse版本并下载。解压下载的文件，
然后执行<code>eclipse</code>文件夹下的eclipse文件。手册后续有专门一章介绍如何<a href="#eclipseDesignerInstallation">安装我们的Eclipse Designer插件</a>。</p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="reporting.problems">1.6. 反馈问题</h3>
<div class="paragraph">
<p>我们希望开发者在报告或提问之前，先看看<a href="http://www.catb.org/~esr/faqs/smart-questions.html">提问的智慧</a>。</p>
</div>
<div class="paragraph">
<p>看完提问的智慧，你可以在<a href="http://forums.flowable.org">用户论坛</a>提问、评论以及提交改进建议，也可以在<a href="https://github.com/flowable/flowable-engine/issues">我们的Github问题跟踪系统</a>创建bug报告。</p>
</div>
</div>
<div class="sect2">
<h3 id="experimental">1.7. 实验性功能</h3>
<div class="paragraph">
<p>标记有<strong>[实验性]</strong>的章节介绍的功能还不够稳定。</p>
</div>
<div class="paragraph">
<p><code>.impl.</code>包下的类都是内部实现类，不保证稳定。但是，在用户手册中作为配置参数介绍的类则是被官方支持的，可以保证稳定。</p>
</div>
</div>
<div class="sect2">
<h3 id="internal">1.8. 内部实现类</h3>
<div class="paragraph">
<p>在JAR文件中，所有<code>.impl.</code>包下的类（比如<code>org.flowable.engine.impl.db</code>）都是实现类，只应在内部使用。实现类中的所有类或接口都不保证稳定。</p>
</div>
</div>
<div class="sect2">
<h3 id="_versioning_strategy">1.9. 版本策略</h3>
<div class="paragraph">
<p>使用三个整数的形式标记版本：<strong>MAJOR.MINOR.MICRO</strong>。其中 <strong>MAJOR</strong>版本代表核心引擎的演进。<strong>MINOR</strong>版本代表新功能与新API。<strong>MICRO</strong>版本代表bug修复与改进。</p>
</div>
<div class="paragraph">
<p>总的来说，Flowable希望在<strong>MINOR</strong>与<strong>MICRO</strong>版本中，对所有非内部实现类保持“源代码兼容性”，即应用可以正确构建，且不改变语义。Flowable也希望在<strong>MINOR</strong>与<strong>MICRO</strong>版本中，保持“二进制兼容性”，即用新版本的Flowable直接替换老版本的Jar文件，仍然可以正常工作。</p>
</div>
<div class="paragraph">
<p>如果在<strong>MINOR</strong>版本中修改了API，将保留原有版本，并使用<em>@Deprecated</em>注解。这种废弃的API将在两个<strong>MINOR</strong>版本之后移除。</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="translator_info">2. 配置</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="configuration">2.1. 创建 DMN 引擎</h3>
<div class="paragraph">
<p><em>Flowable DMN 引擎的构造方式和 Flowable 工作流引擎非常相似。因此，部分文档非常类似流程引擎的相应内容。</em></p>
</div>
<div class="paragraph">
<p>Flowable DMN 引擎是通过名为 <code>flowable.dmn.cfg.xml</code> 的XML文件进行配置的。请注意，如果你使用 <a href="#springintegration">Spring 风格构建 DMN 引擎</a>，则不适用。</p>
</div>
<div class="paragraph">
<p>获取一个 <code>DmnEngine</code> 的最简单的方式是使用 <code>org.flowable.dmn.engine.DmnEngines</code> 类：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1</div></td><td class="code"><span></span><span class="tok-n">DmnEngine</span> <span class="tok-n">dmnEngine</span> <span class="tok-o">=</span> <span class="tok-n">DMNEngines</span><span class="tok-o">.</span><span class="tok-na">getDefaultDmnEngine</span><span class="tok-o">()</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>上述代码将会从classpath寻找 <code>flowable.dmn.cfg.xml</code> 文件，并根据文件中的配置构造引擎。下面的代码片段展示了实例配置。后续章节将详细介绍配置属性。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18</div></td><td class="code"><span></span><span class="tok-nt">&lt;beans</span> <span class="tok-na">xmlns=</span><span class="tok-s">&quot;http://www.springframework.org/schema/beans&quot;</span>
       <span class="tok-na">xmlns:xsi=</span><span class="tok-s">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span>
       <span class="tok-na">xsi:schemaLocation=</span><span class="tok-s">&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&quot;</span><span class="tok-nt">&gt;</span>

  <span class="tok-nt">&lt;bean</span> <span class="tok-na">id=</span><span class="tok-s">&quot;dmnEngineConfiguration&quot;</span> <span class="tok-na">class=</span><span class="tok-s">&quot;org.flowable.dmn.engine.impl.cfg.StandaloneDmnEngineConfiguration&quot;</span><span class="tok-nt">&gt;</span>

    <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;jdbcUrl&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;jdbc:h2:mem:flowable;DB_CLOSE_DELAY=1000&quot;</span> <span class="tok-nt">/&gt;</span>
    <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;jdbcDriver&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;org.h2.Driver&quot;</span> <span class="tok-nt">/&gt;</span>
    <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;jdbcUsername&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;sa&quot;</span> <span class="tok-nt">/&gt;</span>
    <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;jdbcPassword&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;&quot;</span> <span class="tok-nt">/&gt;</span>

    <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;databaseSchemaUpdate&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;true&quot;</span> <span class="tok-nt">/&gt;</span>

    <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;strictMode&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;false&quot;</span><span class="tok-nt">/&gt;</span>

  <span class="tok-nt">&lt;/bean&gt;</span>

<span class="tok-nt">&lt;/beans&gt;</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>可以注意到这个 XML 配置实际上是个 Spring 配置。 <strong>这并不代表 Flowable DMN 只能在 Spring 环境中使用！</strong> 我们只是在内部借助 Spring 的解析和依赖注入能力来构建引擎。</p>
</div>
<div class="paragraph">
<p>也可以通过编程的方式使用配置文件创建 DMNEngineConfiguration 对象。也可以使用不同的 bean ID（比如第三行）。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4
5
6</div></td><td class="code"><span></span><span class="tok-n">DmnEngineConfiguration</span><span class="tok-o">.</span>
  <span class="tok-nf">createDmnEngineConfigurationFromResourceDefault</span><span class="tok-o">();</span>
  <span class="tok-n">createDmnEngineConfigurationFromResource</span><span class="tok-o">(</span><span class="tok-n">String</span> <span class="tok-n">resource</span><span class="tok-o">);</span>
  <span class="tok-n">createDmnEngineConfigurationFromResource</span><span class="tok-o">(</span><span class="tok-n">String</span> <span class="tok-n">resource</span><span class="tok-o">,</span> <span class="tok-n">String</span> <span class="tok-n">beanName</span><span class="tok-o">);</span>
  <span class="tok-n">createDmnEngineConfigurationFromInputStream</span><span class="tok-o">(</span><span class="tok-n">InputStream</span> <span class="tok-n">inputStream</span><span class="tok-o">);</span>
  <span class="tok-n">createDmnEngineConfigurationFromInputStream</span><span class="tok-o">(</span><span class="tok-n">InputStream</span> <span class="tok-n">inputStream</span><span class="tok-o">,</span> <span class="tok-n">String</span> <span class="tok-n">beanName</span><span class="tok-o">);</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>不使用配置文件也是可行的，这将基于默认值创建配置（更多信息请参阅 <a href="#configurationClasses">已支持的其他配置类</a> ）。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2</div></td><td class="code"><span></span><span class="tok-n">DmnEngineConfiguration</span><span class="tok-o">.</span><span class="tok-na">createStandaloneDmnEngineConfiguration</span><span class="tok-o">();</span>
<span class="tok-n">DmnEngineConfiguration</span><span class="tok-o">.</span><span class="tok-na">createStandaloneInMemDmnEngineConfiguration</span><span class="tok-o">();</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>所有的 <code>DmnEngineConfiguration.createXXX()</code> 方法返回一个可做进一步调整的 <code>DmnEngineConfiguration</code> 。调用 <code>buildDmnEngine()</code> 方法之后将创建一个 <code>DmnEngine</code> ：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4</div></td><td class="code"><span></span><span class="tok-n">DmnEngine</span> <span class="tok-n">dmnEngine</span> <span class="tok-o">=</span> <span class="tok-n">DmnEngineConfiguration</span><span class="tok-o">.</span><span class="tok-na">createStandaloneInMemDmnEngineConfiguration</span><span class="tok-o">()</span>
  <span class="tok-o">.</span><span class="tok-na">setDatabaseSchemaUpdate</span><span class="tok-o">(</span><span class="tok-n">DmnEngineConfiguration</span><span class="tok-o">.</span><span class="tok-na">DB_SCHEMA_UPDATE_FALSE</span><span class="tok-o">)</span>
  <span class="tok-o">.</span><span class="tok-na">setJdbcUrl</span><span class="tok-o">(</span><span class="tok-s">&quot;jdbc:h2:mem:my-own-db;DB_CLOSE_DELAY=1000&quot;</span><span class="tok-o">)</span>
  <span class="tok-o">.</span><span class="tok-na">buildDmnEngine</span><span class="tok-o">();</span>
</td></tr></table></code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="configurationRoot">2.2. DmnEngineConfiguration bean</h3>
<div class="paragraph">
<p><code>flowable.dmn.cfg.xml</code> 必须包含一个 ID 为 <code>'dmnEngineConfiguration'</code> 的 bean。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1</div></td><td class="code"><span></span> <span class="tok-nt">&lt;bean</span> <span class="tok-na">id=</span><span class="tok-s">&quot;dmnEngineConfiguration&quot;</span> <span class="tok-na">class=</span><span class="tok-s">&quot;org.flowable.dmn.engine.impl.cfg.StandaloneDmnEngineConfiguration&quot;</span><span class="tok-nt">&gt;</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>这个 bean 将被用于构造 <code>DmnEngine</code>。有多个可选的类可以用来定义 <code>dmnEngineConfiguration</code>。这些类代表了不同的环境，并根据环境设置相应的默认值。最佳方式是选择最符合你的环境的类，尽可能地减少配置引擎所需要的属性。目前有下面这些类可供使用： <a id="configurationClasses"></a></p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>org.flowable.dmn.engine.impl.cfg.StandaloneDmnEngineConfiguration</strong>: 引擎以单机方式运行。Flowable 将自行处理事务。默认情况下，仅在引擎启动时检查数据库（如果 Flowable DMN 相关表不存在，或者版本不正确，将抛出异常）。</p>
</li>
<li>
<p><strong>org.flowable.dmn.engine.impl.cfg.StandaloneInMemDmnEngineConfiguration</strong>: 这是一个方便进行单元测试的类。Flowable DMN 将自行处理事务。默认使用 H2 内存数据库。数据库将随着引擎的启动和关闭进行创建和销毁。使用此类时一般无需进行额外配置。</p>
</li>
<li>
<p><strong>org.flowable.dmn.spring.SpringDmnEngineConfiguration</strong>: 在 Spring 环境中使用 DMN 引擎时使用此类。详见 <a href="#springintegration">与 Spring 集成章节</a>。</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_植入到流程引擎">2.3. 植入到流程引擎</h3>
<div class="paragraph">
<p>除了以独立方式运行，DMN 引擎还可以植入到流程引擎中。这使得流程引擎能够识别它和其他引擎。例如，除了 BPMN 模型，还可以将 DMN 模型部署到流程引擎部署服务 API。</p>
</div>
<div class="paragraph">
<p>要让流程引擎能够识别出 DMN 引擎，需要在流程引擎配置中将 <strong>org.flowable.dmn.engine.configurator.DmnEngineConfigurator</strong> 添加到流程引擎配置 bean 的 configurators list 中</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20</div></td><td class="code"><span></span><span class="tok-nt">&lt;bean</span> <span class="tok-na">id=</span><span class="tok-s">&quot;dmnEngineConfiguration&quot;</span> <span class="tok-na">class=</span><span class="tok-s">&quot;org.flowable.dmn.engine.impl.cfg.StandaloneDmnEngineConfiguration&quot;</span><span class="tok-nt">&gt;</span>
    <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;jdbcUrl&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;jdbc:h2:mem:flowable;DB_CLOSE_DELAY=1000&quot;</span> <span class="tok-nt">/&gt;</span>
    <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;jdbcDriver&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;org.h2.Driver&quot;</span> <span class="tok-nt">/&gt;</span>
    <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;jdbcUsername&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;sa&quot;</span> <span class="tok-nt">/&gt;</span>
    <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;jdbcPassword&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;&quot;</span> <span class="tok-nt">/&gt;</span>
    ...
<span class="tok-nt">&lt;/bean&gt;</span>

<span class="tok-nt">&lt;bean</span> <span class="tok-na">id=</span><span class="tok-s">&quot;dmnEngineConfigurator&quot;</span> <span class="tok-na">class=</span><span class="tok-s">&quot;org.flowable.dmn.engine.configurator.DmnEngineConfigurator&quot;</span><span class="tok-nt">&gt;</span>
    <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;dmnEngineConfiguration&quot;</span> <span class="tok-na">ref=</span><span class="tok-s">&quot;dmnEngineConfiguration&quot;</span> <span class="tok-nt">/&gt;</span>
<span class="tok-nt">&lt;/bean&gt;</span>

<span class="tok-nt">&lt;bean</span> <span class="tok-na">id=</span><span class="tok-s">&quot;processEngineConfiguration&quot;</span> <span class="tok-na">class=</span><span class="tok-s">&quot;org.flowable.engine.impl.cfg.StandaloneProcessEngineConfiguration&quot;</span><span class="tok-nt">&gt;</span>
    <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;configurators&quot;</span><span class="tok-nt">&gt;</span>
      <span class="tok-nt">&lt;list&gt;</span>
        <span class="tok-nt">&lt;ref</span> <span class="tok-na">bean=</span><span class="tok-s">&quot;dmnEngineConfigurator&quot;</span> <span class="tok-nt">/&gt;</span>
      <span class="tok-nt">&lt;/list&gt;</span>
    <span class="tok-nt">&lt;/property&gt;</span>
    ...
<span class="tok-nt">&lt;/bean&gt;</span>
</td></tr></table></code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="databaseConfiguration">2.4. 数据库配置</h3>
<div class="paragraph">
<p>Flowable DMN 引擎有两种方式进行数据库配置。第一种方式是定义数据库的 JDBC 属性：</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>jdbcUrl</strong>: 数据库的 JDBC Url。</p>
</li>
<li>
<p><strong>jdbcDriver</strong>: 特定类型数据库的驱动。</p>
</li>
<li>
<p><strong>jdbcUsername</strong>: 连接数据库所使用的用户名。</p>
</li>
<li>
<p><strong>jdbcPassword</strong>: 连接数据库所使用的密码。</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>基于所提供的 JDBC 属性构造的数据源将使用默认的 <a href="http://www.mybatis.org/">MyBatis</a> 连接池设置。下面这些可选属性可以用来对连接池进行调整（引自 Mybatis 文档）：</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>jdbcMaxActiveConnections</strong>: 连接池在任意时间可以持有的最大活动连接数。</p>
</li>
<li>
<p><strong>jdbcMaxIdleConnections</strong>: 连接池在任意时间可以持有的最大空闲连接数。</p>
</li>
<li>
<p><strong>jdbcMaxCheckoutTime</strong>: 在被强制返回之前，连接池中的连接可被“借用”的时长（以毫秒为单位）。默认值是20000（20秒）。</p>
</li>
<li>
<p><strong>jdbcMaxWaitTime</strong>: 这是一个低级别设置，使池有机会打印日志状态，并在获取连接耗时太久时进行重新尝试（以避免池配置错误时永远静默地失败）。默认值是20000（20秒）。</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>示例数据库配置：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4</div></td><td class="code"><span></span><span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;jdbcUrl&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;jdbc:h2:mem:flowable_dmn;DB_CLOSE_DELAY=1000&quot;</span> <span class="tok-nt">/&gt;</span>
<span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;jdbcDriver&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;org.h2.Driver&quot;</span> <span class="tok-nt">/&gt;</span>
<span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;jdbcUsername&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;sa&quot;</span> <span class="tok-nt">/&gt;</span>
<span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;jdbcPassword&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;&quot;</span> <span class="tok-nt">/&gt;</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>我们的跑分显示 MyBatis 的连接池在处理大量并发请求时不是最高效的。因此，建议使用 javax.sql.DataSource 的实现（比如 HikariCP、Tomcat JDBC 连接池、等等），并将其注入到引擎配置中：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12</div></td><td class="code"><span></span><span class="tok-nt">&lt;bean</span> <span class="tok-na">id=</span><span class="tok-s">&quot;dataSource&quot;</span> <span class="tok-na">class=</span><span class="tok-s">&quot;org.apache.commons.dbcp.BasicDataSource&quot;</span> <span class="tok-nt">&gt;</span>
  <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;driverClassName&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;com.mysql.jdbc.Driver&quot;</span> <span class="tok-nt">/&gt;</span>
  <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;url&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;jdbc:mysql://localhost:3306/flowable_dmn&quot;</span> <span class="tok-nt">/&gt;</span>
  <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;username&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;flowable&quot;</span> <span class="tok-nt">/&gt;</span>
  <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;password&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;flowable&quot;</span> <span class="tok-nt">/&gt;</span>
  <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;defaultAutoCommit&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;false&quot;</span> <span class="tok-nt">/&gt;</span>
<span class="tok-nt">&lt;/bean&gt;</span>

<span class="tok-nt">&lt;bean</span> <span class="tok-na">id=</span><span class="tok-s">&quot;dmnEngineConfiguration&quot;</span> <span class="tok-na">class=</span><span class="tok-s">&quot;org.flowable.dmn.engine.impl.cfg.StandaloneDmnEngineConfiguration&quot;</span><span class="tok-nt">&gt;</span>

    <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;dataSource&quot;</span> <span class="tok-na">ref=</span><span class="tok-s">&quot;dataSource&quot;</span> <span class="tok-nt">/&gt;</span>
    ...
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>要注意的是 Flowable DMN 并不自带定义这种数据源所需要的类库，所以你要确保这些类库在你的classpath中。</p>
</div>
<div class="paragraph">
<p>无论你使用 JDBC 或数据源方式，都可以设置以下属性：</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>databaseType</strong>：一般情况下能从数据库连接中自动识别出来，没必要手工指定。应该仅当自动识别失败时指定。可选的值有：{h2、mysql、oracle、postgres、mssql、db2}。这项设置将决定使用哪些 create/drop 脚本。参见 <a href="#supporteddatabases">“支持的数据库”章节</a> 了解已支持哪些类型的数据库。</p>
</li>
<li>
<p><strong>databaseSchemaUpdate</strong>：用来设置引擎启动和关闭时数据库表的操作策略。</p>
<div class="ulist">
<ul>
<li>
<p><code>false</code> （默认）：在创建引擎时检查数据库表的版本，如果不匹配则抛出异常。</p>
</li>
<li>
<p><code>true</code>：在构建引擎时进行检查，并在必要时更新数据库表。如果表不存在，则创建。</p>
</li>
<li>
<p><code>create-drop</code>：引擎创建时创建表，引擎关闭时删除表。</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="jndiDatasourceConfig">2.5. JNDI 数据源配置</h3>
<div class="paragraph">
<p>默认情况下，Flowable DMN 的数据库配置包含在每个 web 应用的 WEB-INF/classes 下的 db.properties 文件中。但是这样并不理想，因为它使得用户要么修改 Flowable 代码中的 db.properties 并重新编译 WAR 文件，要么在每一次项目部署时解压 WAR 并修改 db.properties。</p>
</div>
<div class="paragraph">
<p>通过 JNDI （Java Naming and Directory Interface）获取数据库连接，这个连接将完全由 Servlet 容器管理，且配置可以在 war 包外部进行管理。而且相比 db.properties 文件，这种方式还能对连接参数进行更多的控制。</p>
</div>
<div class="sect3">
<h4 id="jndi_configuration">2.5.1. 配置</h4>
<div class="paragraph">
<p>JNDI 数据源的配置将视你所使用的 servlet 容器而有所不同。下面的说明适用于 Tomcat，至于其他的容器，请参阅各容器的文档。</p>
</div>
<div class="paragraph">
<p>如果使用 Tomcat，JNDI 资源配置在 $CATALINA_BASE/conf/[enginename]/[hostname]/[warname].xml 中（Flowable UI 的配置通常在 $CATALINA_BASE/conf/Catalina/localhost/flowable-app.xml）。默认的 context 是在应用初次部署时从 Flowable WAR 文件中复制过来的，所以如果已经存在的话你需要进行替换。比如，要使用 MySql 而不是 H2，可如下修改 JNDI 资源：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16</div></td><td class="code"><span></span><span class="tok-cp">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
    <span class="tok-nt">&lt;Context</span> <span class="tok-na">antiJARLocking=</span><span class="tok-s">&quot;true&quot;</span> <span class="tok-na">path=</span><span class="tok-s">&quot;/flowable-app&quot;</span><span class="tok-nt">&gt;</span>
        <span class="tok-nt">&lt;Resource</span> <span class="tok-na">auth=</span><span class="tok-s">&quot;Container&quot;</span>
            <span class="tok-na">name=</span><span class="tok-s">&quot;jdbc/flowableDB&quot;</span>
            <span class="tok-na">type=</span><span class="tok-s">&quot;javax.sql.DataSource&quot;</span>
            <span class="tok-na">description=</span><span class="tok-s">&quot;JDBC DataSource&quot;</span>
            <span class="tok-na">url=</span><span class="tok-s">&quot;jdbc:mysql://localhost:3306/flowable&quot;</span>
            <span class="tok-na">driverClassName=</span><span class="tok-s">&quot;com.mysql.jdbc.Driver&quot;</span>
            <span class="tok-na">username=</span><span class="tok-s">&quot;sa&quot;</span>
            <span class="tok-na">password=</span><span class="tok-s">&quot;&quot;</span>
            <span class="tok-na">defaultAutoCommit=</span><span class="tok-s">&quot;false&quot;</span>
            <span class="tok-na">initialSize=</span><span class="tok-s">&quot;5&quot;</span>
            <span class="tok-na">maxWait=</span><span class="tok-s">&quot;5000&quot;</span>
            <span class="tok-na">maxActive=</span><span class="tok-s">&quot;120&quot;</span>
            <span class="tok-na">maxIdle=</span><span class="tok-s">&quot;5&quot;</span><span class="tok-nt">/&gt;</span>
        <span class="tok-nt">&lt;/Context&gt;</span>
</td></tr></table></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_jndi_属性">2.5.2. JNDI 属性</h4>
<div class="paragraph">
<p>要配置 JNDI 数据源，使用下面这些 Flowable UI 的 properties 文件中的属性：</p>
</div>
<div class="ulist">
<ul>
<li>
<p>spring.datasource.jndi-name=：数据源的 JNDI 名称。</p>
</li>
<li>
<p>datasource.jndi.resourceRef：设置查询是否发生在 J2EE 容器中，换句话说，JNDI 名称中不包含前缀“java:comp/env/”时是否要把它加上。默认“true”。</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect2">
<h3 id="supporteddatabases">2.6. 支持的数据库</h3>
<div class="paragraph">
<p>下面列出了 Flowable 所使用的数据库的类型（区分大小写！）。</p>
</div>
<table id="databaseTypes" class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Flowable DMN 数据库类型</th>
<th class="tableblock halign-left valign-top">JDBC URL 示例</th>
<th class="tableblock halign-left valign-top">备注</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">h2</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">jdbc:h2:tcp://localhost/flowable_dmn</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">默认数据库</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">mysql</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">jdbc:mysql://localhost:3306/flowable_dmn?autoReconnect=true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">已使用 mysql-connector-java 数据库驱动进行测试</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">oracle</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">jdbc:oracle:thin:@localhost:1521:xe</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">postgres</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">jdbc:postgresql://localhost:5432/flowable_dmn</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">db2</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">jdbc:db2://localhost:50000/flowable_dmn</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">mssql</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">jdbc:sqlserver://localhost:1433;databaseName=flowable_dmn (jdbc.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver) <em>OR</em> jdbc:jtds:sqlserver://localhost:1433/flowable_dmn (jdbc.driver=net.sourceforge.jtds.jdbc.Driver)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">已使用 Microsoft JDBC Driver 4.0（sqljdbc4.jar）和 JTDS 驱动进行测试</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="creatingDatabaseTable">2.7. 创建数据库表</h3>
<div class="paragraph">
<p>Flowable DMN 使用 <a href="http://www.liquibase.org">Liquibase</a> 跟踪、管理和应用数据库表的变更。</p>
</div>
<div class="paragraph">
<p>创建数据库表的最简单的方式是：</p>
</div>
<div class="ulist">
<ul>
<li>
<p>将 flowable-dmn-engine 相关JAR包添加到 classpath</p>
</li>
<li>
<p>添加合适的数据库驱动</p>
</li>
<li>
<p>添加 Flowable 配置文件（<em>flowable.dmn.cfg.xml</em>）到 classpath，指向你的数据库（参阅 <a href="#databaseConfiguration">“数据库配置”章节</a>）</p>
</li>
<li>
<p>执行 <em>DbSchemaCreate</em> 类的 main 方法</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="database.tables.explained">2.8. 数据库表名称说明</h3>
<div class="paragraph">
<p>Flowable DMN 的表名全部以 <strong>ACT_DMN_</strong> 开头。</p>
</div>
<div class="ulist">
<ul>
<li>
<p>ACT_DMN_DATABASECHANGELOG：此表用于 Liquibase 对已运行的变更进行追踪。</p>
</li>
<li>
<p>ACT_DMN_DATABASECHANGELOGLOCK：此表用于 Liquibase 确保同时只有一个 Liquibase 实例在运行。</p>
</li>
<li>
<p>ACT_DMN_DECISION_TABLE：此表包含了已部署的决策表的元数据。</p>
</li>
<li>
<p>ACT_DMN_DEPLOYMENT：此表包含了每次部署行为的元数据。</p>
</li>
<li>
<p>ACT_DMN_DEPLOYMENT_RESOURCE：此表包含了 DMN 定义的资源和元数据。</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="databaseUpgrade">2.9. 数据库升级</h3>
<div class="paragraph">
<p>请确保在升级前已对数据库进行备份。</p>
</div>
<div class="paragraph">
<p>每当引擎被创建时默认都会进行版本检查。版本检查通常在你的应用程序或者 Flowable web 应用启动时发生。如果 Flowable 库发现库版本和数据库表版本不同，则抛出异常。</p>
</div>
<div class="paragraph">
<p>要进行升级，你首先需要在 flowable.dmn.cfg.xml 配置文件中加入如下配置属性：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4
5
6
7
8
9</div></td><td class="code"><span></span><span class="tok-nt">&lt;beans</span> <span class="tok-nt">&gt;</span>

  <span class="tok-nt">&lt;bean</span> <span class="tok-na">id=</span><span class="tok-s">&quot;dmnEngineConfiguration&quot;</span> <span class="tok-na">class=</span><span class="tok-s">&quot;org.flowable.dmn.engine.impl.cfg.StandaloneDmnEngineConfiguration&quot;</span><span class="tok-nt">&gt;</span>
    <span class="tok-c">&lt;!-- ... --&gt;</span>
    <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;databaseSchemaUpdate&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;true&quot;</span> <span class="tok-nt">/&gt;</span>
    <span class="tok-c">&lt;!-- ... --&gt;</span>
  <span class="tok-nt">&lt;/bean&gt;</span>

<span class="tok-nt">&lt;/beans&gt;</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>另外，在classpath中引入适合你数据库的驱动。</strong> 升级应用程序中的 Flowable DMN 类库，或者启动一个新版本的 Flowable DMN 并将其指向旧版本的数据库。当 databaseSchemaUpdate 设置为 true 时，Flowable DMN 将会在首次发现类库版本和数据库表版本不同时升级到新版本。</p>
</div>
</div>
<div class="sect2">
<h3 id="processDefinitionCacheConfiguration">2.10. 部署缓存配置</h3>
<div class="paragraph">
<p>为了避免每次需要决策表时都去访问数据库，同时也因为决策表不会改变，所有的决策都是被缓存的（在它们经过解析之后）。缓存默认是没有限制的。可添加如下属性对决策缓存进行限制：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1</div></td><td class="code"><span></span><span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;decisionCacheLimit&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;10&quot;</span> <span class="tok-nt">/&gt;</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>这项设置将使用给定了硬性限制的 LRU 缓存替代默认的 hashmap 缓存。当然，最合适的取值取决于决策总数以及运行时实际使用到的决策数。</p>
</div>
<div class="paragraph">
<p>你还可以注入你自己的缓存实现。必须是一个实现了 org.flowable.dmn.engine.impl.persistence.deploy.DeploymentCache 接口的 bean：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3</div></td><td class="code"><span></span><span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;decisionCache&quot;</span><span class="tok-nt">&gt;</span>
  <span class="tok-nt">&lt;bean</span> <span class="tok-na">class=</span><span class="tok-s">&quot;org.flowable.MyCache&quot;</span> <span class="tok-nt">/&gt;</span>
<span class="tok-nt">&lt;/property&gt;</span>
</td></tr></table></code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="strictMode">2.11. 严格模式</h3>
<div class="paragraph">
<p>严格模式是默认 <strong>启用</strong> 的。就是说命中策略（hit policies）将按照 DMN 1.1 标准执行。也可以禁用严格模式。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4
5
6
7
8
9</div></td><td class="code"><span></span><span class="tok-nt">&lt;beans&gt;</span>

  <span class="tok-nt">&lt;bean</span> <span class="tok-na">id=</span><span class="tok-s">&quot;dmnEngineConfiguration&quot;</span> <span class="tok-na">class=</span><span class="tok-s">&quot;org.flowable.dmn.engine.impl.cfg.StandaloneDmnEngineConfiguration&quot;</span><span class="tok-nt">&gt;</span>
    <span class="tok-c">&lt;!-- ... --&gt;</span>
      <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;strictMode&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;false&quot;</span><span class="tok-nt">/&gt;</span>
    <span class="tok-c">&lt;!-- ... --&gt;</span>
  <span class="tok-nt">&lt;/bean&gt;</span>

<span class="tok-nt">&lt;/beans&gt;</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>这样做的影响是违反了命中策略约束时，结果不会作废。可能的违规将被作为验证信息记录到审核日志中。</p>
</div>
</div>
<div class="sect2">
<h3 id="_自定义_flowable_函数委托function_delegates">2.12. 自定义 Flowable 函数委托（Function Delegates）</h3>
<div class="paragraph">
<p>Flowable DMN 内置了一些 JUEL 函数委托。通过设置 dmnEngineConfiguration bean 的 <strong>customFlowableFunctionDelegates</strong> 属性，你可以使用自己的实现。这些（函数委托）可以在表达式（expressions）中执行你自己的逻辑。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17</div></td><td class="code"><span></span><span class="tok-nt">&lt;beans&gt;</span>

  <span class="tok-nt">&lt;bean</span> <span class="tok-na">id=</span><span class="tok-s">&quot;dmnEngineConfiguration&quot;</span> <span class="tok-na">class=</span><span class="tok-s">&quot;org.flowable.dmn.engine.impl.cfg.StandaloneDmnEngineConfiguration&quot;</span><span class="tok-nt">&gt;</span>
    <span class="tok-c">&lt;!-- ... --&gt;</span>
    <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;customFlowableFunctionDelegates&quot;</span><span class="tok-nt">&gt;</span>
      <span class="tok-nt">&lt;list&gt;</span>
          <span class="tok-nt">&lt;bean</span> <span class="tok-na">ref=</span><span class="tok-s">&quot;myOwnFunctionDelegateOne&quot;</span> <span class="tok-nt">/&gt;</span>
          <span class="tok-nt">&lt;bean</span> <span class="tok-na">ref=</span><span class="tok-s">&quot;myOwnFunctionDelegateTwo&quot;</span> <span class="tok-nt">/&gt;</span>
      <span class="tok-nt">&lt;/list&gt;</span>
    <span class="tok-nt">&lt;/property&gt;</span>
    <span class="tok-c">&lt;!-- ... --&gt;</span>
  <span class="tok-nt">&lt;/bean&gt;</span>

  <span class="tok-nt">&lt;bean</span> <span class="tok-na">id=</span><span class="tok-s">&quot;myOwnFunctionDelegateOne&quot;</span> <span class="tok-na">class=</span><span class="tok-s">&quot;org.acme.MyOwnFunctionDelegateOne&quot;</span> <span class="tok-nt">/&gt;</span>
  <span class="tok-nt">&lt;bean</span> <span class="tok-na">id=</span><span class="tok-s">&quot;myOwnFunctionDelegateTwo&quot;</span> <span class="tok-na">class=</span><span class="tok-s">&quot;org.acme.MyOwnFunctionDelegateTwo&quot;</span> <span class="tok-nt">/&gt;</span>

<span class="tok-nt">&lt;/beans&gt;</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>请注意，自定义函数委托必须继承自 org.flowable.engine.common.impl.el.AbstractFlowableFunctionDelegate。</p>
</div>
</div>
<div class="sect2">
<h3 id="loggingConfiguration">2.13. 日志</h3>
<div class="paragraph">
<p>所有日志（flowable、spring、mybatis、&#8230;&#8203;）都通过 slf4j 门面进行记录，所以你可以自行选择日志框架。</p>
</div>
<div class="paragraph">
<p><strong>flowable 引擎依赖项中默认没有包含具体的日志实现框架；你应该将你选择的日志框架添加到你的项目中。</strong> 如果没有引入日志实现框架的 jar 包，slf4j 不会记录任何日志，只会给出一个不会记录任何内容的警告。</p>
</div>
<div class="paragraph">
<p>举个例子，使用 maven 时，像这样添加依赖（以使用 log4j 为例），请注意这里省略了版本：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4</div></td><td class="code"><span></span><span class="tok-nt">&lt;dependency&gt;</span>
  <span class="tok-nt">&lt;groupId&gt;</span>org.slf4j<span class="tok-nt">&lt;/groupId&gt;</span>
  <span class="tok-nt">&lt;artifactId&gt;</span>slf4j-log4j12<span class="tok-nt">&lt;/artifactId&gt;</span>
<span class="tok-nt">&lt;/dependency&gt;</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>flowable-ui 和 flowable-rest webapps 使用 log4j。运行所有的 flowable-* mudules 测试时同样使用 log4j。</p>
</div>
<div class="paragraph">
<p><strong>所用容器的 classpath 中带有 commons-logging 时的重要注意事项：</strong> 为了能通过 slf4j 能调用到 spring-logging，使用了一个桥（a bridge is used）（详见 <a href="http://www.slf4j.org/legacy.html#jclOverSLF4J"><a href="http://www.slf4j.org/legacy.html#jclOverSLF4J" class="bare">http://www.slf4j.org/legacy.html#jclOverSLF4J</a></a>）。如果你的容器提供了 commons-logging 实现，请按此页面的说明进行操作，以确保稳定：<a href="http://www.slf4j.org/codes.html#release"><a href="http://www.slf4j.org/codes.html#release" class="bare">http://www.slf4j.org/codes.html#release</a></a>。</p>
</div>
<div class="paragraph">
<p>Maven 示例（忽略了版本）:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4</div></td><td class="code"><span></span><span class="tok-nt">&lt;dependency&gt;</span>
  <span class="tok-nt">&lt;groupId&gt;</span>org.slf4j<span class="tok-nt">&lt;/groupId&gt;</span>
  <span class="tok-nt">&lt;artifactId&gt;</span>jcl-over-slf4j<span class="tok-nt">&lt;/artifactId&gt;</span>
<span class="tok-nt">&lt;/dependency&gt;</span>
</td></tr></table></code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="chapterApi">3. Flowable DMN API</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="apiEngine">3.1. DMN引擎API和服务</h3>
<div class="paragraph">
<p>DMN引擎API是与Flowable DMN交互的最常见方式。中心起点是<code>DmnEngine</code>，可以通过<a href="#configuration">configuration section</a>部分中描述的多种方式创建。从DmnEngine中，您可以获得各种其他服务。</p>
</div>
<div class="paragraph">
<p>DmnEngine和服务对象是线程安全的。因此，您可以为整个服务器保留对其中一个的引用。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4</div></td><td class="code"><span></span><span class="tok-n">DmnEngine</span> <span class="tok-n">dmnEngine</span> <span class="tok-o">=</span> <span class="tok-n">DmnEngines</span><span class="tok-o">.</span><span class="tok-na">getDefaultDmnEngine</span><span class="tok-o">();</span>
<span class="tok-n">DmnRuleService</span> <span class="tok-n">dmnRuleService</span> <span class="tok-o">=</span> <span class="tok-n">dmnEngine</span><span class="tok-o">.</span><span class="tok-na">getDmnRuleService</span><span class="tok-o">();</span>
<span class="tok-n">DmnRepositoryService</span> <span class="tok-n">dmnRepositoryService</span> <span class="tok-o">=</span> <span class="tok-n">dmnEngine</span><span class="tok-o">.</span><span class="tok-na">getDmnRepositoryService</span><span class="tok-o">();</span>
<span class="tok-n">DmnManagementService</span> <span class="tok-n">dmnManagementService</span> <span class="tok-o">=</span> <span class="tok-n">dmnEngine</span><span class="tok-o">.</span><span class="tok-na">getDmnManagementService</span><span class="tok-o">();</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p><code>DmnEngines.getDefaultDmnEngine()</code> 将在第一次调用时初始化并构建DMN引擎，之后始终返回相同的DMN引擎。 可以使用适当的DMNEngines.init()创建和DMNEngines.destroy()关闭所有DMN引擎。</p>
</div>
<div class="paragraph">
<p>DmnEngines类将扫描所有 <code>flowable.dmn.cfg.xml</code> 和 <code>flowable-dmn-context.xml</code> 文件。对所有 <code>flowable.dmn.cfg.xml</code> 文件， DMN引擎将以典型的Flowable方式构建：<code>DmnEngineConfiguration.createDmnEngineConfigurationFromInputStream(inputStream).buildDmnEngine()</code>. 对所有 <code>flowable-dmn-context.xml</code> 文件，DMN引擎将以Spring方式构建： 首先创建Spring应用程序上下文，然后从该应用程序上下文中获取DMN引擎。</p>
</div>
<div class="paragraph">
<p>所有服务都是无状态的。这意味着您可以在群集中的多个节点上轻松运行Flowable DMN，每个都进入同一个数据库，而不必担心哪台机器实际执行了以前的调用。对任何服务的任何调用都是幂等的，无论它在何处执行。</p>
</div>
<div class="paragraph">
<p>DmnRepositoryService可能是使用Flowable DMN引擎时所需的第一个服务。此服务提供用于管理、操作部署和DMN定义的操作。 DMN定义是DMN模型的根本概念(DMN的主要概念在&lt;dmn-introduction, DMN introduction section&gt;中有解释). 它包含决策的定义（及其决策表）。
 部署是Flowable DMN引擎中的打包的单位。部署可以包含多个DMN XML文件。 发布部署意味着将其部署到引擎表，在存储到数据库中之前检查和解析所有DMN定义。从那时起，系统就知道部署，现在可以执行部署中包含的任何决策。</p>
</div>
<div class="paragraph">
<p>此外，此服务允许您：</p>
</div>
<div class="ulist">
<ul>
<li>
<p>查询引擎已知的部署，DMN定义和决策表。</p>
</li>
<li>
<p>检索可用于使用Java而不是XML进行内省的DMN定义或决策表的POJO版本。</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><strong>DmnRuleService</strong> 提供了执行决策的方法。通过提供参数和输入数据，可以开始评估决策。</p>
</div>
<div class="paragraph">
<p>使用Flowable DMN编写自定义应用程序时，通常不需要 <strong>DmnManagementService</strong> 。 它允许您检索有关引擎版本，数据库表和表元数据的信息。</p>
</div>
<div class="paragraph">
<p>有关服务操作和DMN引擎API的更多详细信息，查看链接：http://www.flowable.org/docs/javadocs/index.html[the javadocs].</p>
</div>
</div>
<div class="sect2">
<h3 id="_异常策略">3.2. 异常策略</h3>
<div class="paragraph">
<p>Flowable中的基本异常是 <code>org.flowable.engine.FlowableException</code>,一个 unchecked 异常。 API可以随时抛出此异常，但在特定方法中发生的“预期”异常将记录在链接:http://www.flowable.org/docs/javadocs/index.html[ the javadocs]. 例如， 来自 <code>DmnRuleService</code> 的提取物:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12</div></td><td class="code"><span></span><span class="tok-cm">/**</span>
<span class="tok-cm">  * Execute a decision identified by it&#39;s key.</span>
<span class="tok-cm">  *</span>
<span class="tok-cm">  * @param  decisionKey      the decision key, cannot be null</span>
<span class="tok-cm">  * @param  inputVariables   map with input variables</span>
<span class="tok-cm">  * @return                  the {@link RuleEngineExecutionResult} for this execution</span>
<span class="tok-cm">  * @throws FlowableObjectNotFoundException</span>
<span class="tok-cm">  *            when the decision with given key does not exist.</span>
<span class="tok-cm">  * @throws FlowableException</span>
<span class="tok-cm">  *           when an error occurs while executing the decision.</span>
<span class="tok-cm">  */</span>
<span class="tok-n">RuleEngineExecutionResult</span> <span class="tok-nf">executeDecisionByKey</span><span class="tok-o">(</span><span class="tok-n">String</span> <span class="tok-n">decisionKey</span><span class="tok-o">,</span> <span class="tok-n">Map</span><span class="tok-o">&lt;</span><span class="tok-n">String</span><span class="tok-o">,</span> <span class="tok-n">Object</span><span class="tok-o">&gt;</span> <span class="tok-n">inputVariables</span><span class="tok-o">);</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>在上面的示例中，当传递的密钥没有任何决策时，将抛出异常。此外，由于javadoc  <strong>明确声明decisionKey不能为null，当传递null时，将抛出 FlowableIllegalArgumentException</strong> 。</p>
</div>
<div class="paragraph">
<p>即使我们想要避免一个大的异常层次结构，在特定情况下会抛出以下子类。在流程执行或API调用期间发生的所有其他错误都不符合以下可能的异常，这些错误将作为常规<code> FlowableExceptions </code> 抛出。</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>FlowableOptimisticLockingException</code>: 在由同一数据条目的并发访问引起的数据存储中发生乐观锁定时抛出。</p>
</li>
<li>
<p><code>FlowableClassLoadingException</code>: 未找到请求加载的类或加载时发生错误时抛出。</p>
</li>
<li>
<p><code>FlowableObjectNotFoundException</code>: 当请求或操作的对象不存在时抛出。</p>
</li>
<li>
<p><code>FlowableIllegalArgumentException</code>: 指示在Flowable DMN API调用中提供了非法参数的异常，在引擎的配置中配置了非法值，或者提供了非法值。</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="queryAPI">3.3. 查询 API</h3>
<div class="paragraph">
<p>有两种方法可以从引擎查询数据：查询API和本机查询。 Query API允许使用流畅的API对完全类型安全的查询进行编程。您可以为查询添加各种条件（所有这些条件作为逻辑AND一起应用）并且恰好是一个排序。以下代码显示了一个示例：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4</div></td><td class="code"><span></span><span class="tok-n">List</span><span class="tok-o">&lt;</span><span class="tok-n">DmnDeployment</span><span class="tok-o">&gt;</span> <span class="tok-n">dmnDeployments</span> <span class="tok-o">=</span> <span class="tok-n">dmnRepositoryService</span><span class="tok-o">.</span><span class="tok-na">createDeploymentQuery</span><span class="tok-o">()</span>
    <span class="tok-o">.</span><span class="tok-na">deploymentNameLike</span><span class="tok-o">(</span><span class="tok-s">&quot;deployment%&quot;</span><span class="tok-o">)</span>
    <span class="tok-o">.</span><span class="tok-na">orderByDeployTime</span><span class="tok-o">()</span>
    <span class="tok-o">.</span><span class="tok-na">list</span><span class="tok-o">();</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>有时您需要更强大的查询，例如，使用OR运算符的查询或使用Query API无法表达的限制。对于这些情况，我们引入了本机查询，允许您编写自己的SQL查询。返回类型由您使用的Query对象定义，数据映射到正确的对象，例如Deployment，ProcessInstance，Execution等。由于查询将在数据库中触发，因此必须使用在数据库中定义的表名和列名;这需要一些有关内部数据结构的知识，建议您谨慎使用本机查询。可以通过API检索表名，以使依赖性尽可能小。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4
5
6
7
8</div></td><td class="code"><span></span>
<span class="tok-kt">long</span> <span class="tok-n">count</span> <span class="tok-o">=</span> <span class="tok-n">dmnRepositoryService</span><span class="tok-o">.</span><span class="tok-na">createNativeDeploymentQuery</span><span class="tok-o">()</span>
    <span class="tok-o">.</span><span class="tok-na">sql</span><span class="tok-o">(</span><span class="tok-s">&quot;SELECT count(*) FROM &quot;</span> <span class="tok-o">+</span> <span class="tok-n">dmnManagementService</span><span class="tok-o">.</span><span class="tok-na">getTableName</span><span class="tok-o">(</span><span class="tok-n">DmnDeploymentEntity</span><span class="tok-o">.</span><span class="tok-na">class</span><span class="tok-o">)</span> <span class="tok-o">+</span> <span class="tok-s">&quot; D1, &quot;</span>
        <span class="tok-o">+</span> <span class="tok-n">dmnManagementService</span><span class="tok-o">.</span><span class="tok-na">getTableName</span><span class="tok-o">(</span><span class="tok-n">DecisionTableEntity</span><span class="tok-o">.</span><span class="tok-na">class</span><span class="tok-o">)</span> <span class="tok-o">+</span> <span class="tok-s">&quot; D2 &quot;</span>
        <span class="tok-o">+</span> <span class="tok-s">&quot;WHERE D1.ID_ = D2.DEPLOYMENT_ID_ &quot;</span>
        <span class="tok-o">+</span> <span class="tok-s">&quot;AND D1.ID_ = #{deploymentId}&quot;</span><span class="tok-o">)</span>
    <span class="tok-o">.</span><span class="tok-na">parameter</span><span class="tok-o">(</span><span class="tok-s">&quot;deploymentId&quot;</span><span class="tok-o">,</span> <span class="tok-n">deployment</span><span class="tok-o">.</span><span class="tok-na">getId</span><span class="tok-o">())</span>
    <span class="tok-o">.</span><span class="tok-na">count</span><span class="tok-o">();</span>
</td></tr></table></code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="apiUnitTesting">3.4. 单元测试</h3>
<div class="paragraph">
<p>由于Flowable DMN是一个可嵌入的Java引擎，因此编写DMN定义的单元测试就像编写常规单元测试一样简单。</p>
</div>
<div class="paragraph">
<p>Flowable支持JUnit版本4和5样式的单元测试。</p>
</div>
<div class="paragraph">
<p>在JUnit 5样式中，需要使用 org.flowable.dmn.engine.test.FlowableDmnTest 注解
 或手动注册 org.flowable.dmn.engine.test.FlowableDmnExtension 。
 FlowableDmnTest 注解只是一个元注解，并且注册了 FlowableDmnExtension
 (即 <code>@ExtendWith(FlowableDmnExtension.class)</code>).
 这将使DmnEngine和服务可用作测试和生命周期方法的参数
 (<code>@BeforeAll</code>, <code>@BeforeEach</code>, <code>@AfterEach</code>, <code>@AfterAll</code>).
 在每次测试之前，默认情况下将使用类路径上的 flowable.dmn.cfg.xml 资源初始化dmnEngine。
 为了指定不同的配置文件需要使用org.flowable.dmn.engine.test.DmnConfigurationResource 注解（参见第二个例子）。
 当配置资源相同时，Dmn引擎将在多个单元测试中静态缓存。</p>
</div>
<div class="paragraph">
<p>通过使用 FlowableDmnExtension ，您可以在测试方法上使用 org.flowable.dmn.engine.test.DmnDeployment 注解或 org.flowable.dmn.engine.test.DmnDeploymentAnnotation 注解。
 如果同时使用 @DmnDeployment 和 @DmnDeploymentAnnotatio 那么 @DmnDeployment 优先，@DmnDeploymentAnnotation 将被忽略。
 在测试方法上使用 @DmnDeployment 注解时，在每次测试之前，将部署 DmnDeployment＃resources 中定义的dmn文件。
 如果没有定义资源，则为 testClassName.testMethod.dmn 形式的资源文件，将在与测试类相同的包中进行部署。
 在测试结束时，部署将被删除，包括所有相关的dmn定义，执行等。
 有关更多信息，请参阅 DmnDeployment 类。</p>
</div>
<div class="paragraph">
<p>考虑到所有这些，JUnit 5测试看起来如下：</p>
</div>
<div class="listingblock">
<div class="title">使用默认资源进行JUnit 5测试</div>
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17</div></td><td class="code"><span></span><span class="tok-nd">@FlowableDmnTest</span>
<span class="tok-kd">class</span> <span class="tok-nc">MyDecisionTableTest</span> <span class="tok-o">{</span>

  <span class="tok-nd">@Test</span>
  <span class="tok-nd">@DmnDeploymentAnnotation</span>
  <span class="tok-kt">void</span> <span class="tok-nf">simpleDmnTest</span><span class="tok-o">(</span><span class="tok-n">DmnEngine</span> <span class="tok-n">dmnEngine</span><span class="tok-o">)</span> <span class="tok-o">{</span>
    <span class="tok-n">DmnRuleService</span> <span class="tok-n">dmnRuleService</span> <span class="tok-o">=</span> <span class="tok-n">dmnEngine</span><span class="tok-o">.</span><span class="tok-na">getDmnRuleService</span><span class="tok-o">();</span>

    <span class="tok-n">Map</span><span class="tok-o">&lt;</span><span class="tok-n">String</span><span class="tok-o">,</span> <span class="tok-n">Object</span><span class="tok-o">&gt;</span> <span class="tok-n">executionResult</span> <span class="tok-o">=</span> <span class="tok-n">ruleService</span><span class="tok-o">.</span><span class="tok-na">createExecuteDecisionBuilder</span><span class="tok-o">()</span>
            <span class="tok-o">.</span><span class="tok-na">decisionKey</span><span class="tok-o">(</span><span class="tok-s">&quot;extensionUsage&quot;</span><span class="tok-o">)</span>
            <span class="tok-o">.</span><span class="tok-na">variable</span><span class="tok-o">(</span><span class="tok-s">&quot;inputVariable1&quot;</span><span class="tok-o">,</span> <span class="tok-mi">2</span><span class="tok-o">)</span>
            <span class="tok-o">.</span><span class="tok-na">variable</span><span class="tok-o">(</span><span class="tok-s">&quot;inputVariable2&quot;</span><span class="tok-o">,</span> <span class="tok-s">&quot;test2&quot;</span><span class="tok-o">)</span>
            <span class="tok-o">.</span><span class="tok-na">executeWithSingleResult</span><span class="tok-o">();</span>

    <span class="tok-n">Assertions</span><span class="tok-o">.</span><span class="tok-na">assertThat</span><span class="tok-o">(</span><span class="tok-n">executionResult</span><span class="tok-o">).</span><span class="tok-na">containsEntry</span><span class="tok-o">(</span><span class="tok-s">&quot;output1&quot;</span><span class="tok-o">,</span> <span class="tok-s">&quot;test1&quot;</span><span class="tok-o">);</span>
  <span class="tok-o">}</span>
<span class="tok-o">}</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre>使用JUnit 5，您还可以将部署的ID（带有org.flowable.dmn.engine.test.DmnDeploymentId_）注入到测试和生命周期方法中。</pre>
</div>
</div>
<div class="listingblock">
<div class="title">使用自定义资源进行JUnit 5测试</div>
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18</div></td><td class="code"><span></span><span class="tok-nd">@FlowableDmnTest</span>
<span class="tok-nd">@DmnConfigurationResource</span><span class="tok-o">(</span><span class="tok-s">&quot;flowable.custom.dmn.cfg.xml&quot;</span><span class="tok-o">)</span>
<span class="tok-kd">class</span> <span class="tok-nc">MyDecisionTableTest</span> <span class="tok-o">{</span>

  <span class="tok-nd">@Test</span>
  <span class="tok-nd">@DmnDeploymentAnnotation</span>
  <span class="tok-kt">void</span> <span class="tok-nf">simpleDmnTest</span><span class="tok-o">(</span><span class="tok-n">DmnEngine</span> <span class="tok-n">dmnEngine</span><span class="tok-o">)</span> <span class="tok-o">{</span>
    <span class="tok-n">DmnRuleService</span> <span class="tok-n">dmnRuleService</span> <span class="tok-o">=</span> <span class="tok-n">dmnEngine</span><span class="tok-o">.</span><span class="tok-na">getDmnRuleService</span><span class="tok-o">();</span>

    <span class="tok-n">Map</span><span class="tok-o">&lt;</span><span class="tok-n">String</span><span class="tok-o">,</span> <span class="tok-n">Object</span><span class="tok-o">&gt;</span> <span class="tok-n">executionResult</span> <span class="tok-o">=</span> <span class="tok-n">ruleService</span><span class="tok-o">.</span><span class="tok-na">createExecuteDecisionBuilder</span><span class="tok-o">()</span>
            <span class="tok-o">.</span><span class="tok-na">decisionKey</span><span class="tok-o">(</span><span class="tok-s">&quot;extensionUsage&quot;</span><span class="tok-o">)</span>
            <span class="tok-o">.</span><span class="tok-na">variable</span><span class="tok-o">(</span><span class="tok-s">&quot;inputVariable1&quot;</span><span class="tok-o">,</span> <span class="tok-mi">2</span><span class="tok-o">)</span>
            <span class="tok-o">.</span><span class="tok-na">variable</span><span class="tok-o">(</span><span class="tok-s">&quot;inputVariable2&quot;</span><span class="tok-o">,</span> <span class="tok-s">&quot;test2&quot;</span><span class="tok-o">)</span>
            <span class="tok-o">.</span><span class="tok-na">executeWithSingleResult</span><span class="tok-o">();</span>

    <span class="tok-n">Assertions</span><span class="tok-o">.</span><span class="tok-na">assertThat</span><span class="tok-o">(</span><span class="tok-n">executionResult</span><span class="tok-o">).</span><span class="tok-na">containsEntry</span><span class="tok-o">(</span><span class="tok-s">&quot;output1&quot;</span><span class="tok-o">,</span> <span class="tok-s">&quot;test1&quot;</span><span class="tok-o">);</span>
  <span class="tok-o">}</span>
<span class="tok-o">}</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>在编写JUnit 4单元测试时，可以使用 org.flowable.dmn.engine.test.FlowableDmnRule 规则。通过此规则，DMN引擎和服务可通过getter获得。包含此 Rule 将启用注解 org.flowable.dmn.engine.test.DmnDeploymentAnnotation (请参阅上文，了解其使用和配置) 它将在类路径中查找默认配置文件。 当使用相同的配置资源时，DMN引擎可以在多个单元测试中静态缓存。
也可以为规则提供自定义引擎配置。</p>
</div>
<div class="paragraph">
<p>以下代码片段显示了使用JUnit 4测试样式和 FlowableDmnRule 的用法的示例（并传递可选的自定义配置）：</p>
</div>
<div class="listingblock">
<div class="title">JUnit 4 test</div>
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20</div></td><td class="code"><span></span><span class="tok-kd">public</span> <span class="tok-kd">class</span> <span class="tok-nc">MyDecisionTableTest</span> <span class="tok-o">{</span>

  <span class="tok-nd">@Rule</span>
  <span class="tok-kd">public</span> <span class="tok-n">FlowableDmnRule</span> <span class="tok-n">flowableDmnRule</span> <span class="tok-o">=</span> <span class="tok-k">new</span> <span class="tok-n">FlowableDmnRule</span><span class="tok-o">(</span><span class="tok-s">&quot;custom1.flowable.dmn.cfg.xml&quot;</span><span class="tok-o">);</span>

  <span class="tok-nd">@Test</span>
  <span class="tok-nd">@DmnDeploymentAnnotation</span>
  <span class="tok-kd">public</span> <span class="tok-kt">void</span> <span class="tok-nf">ruleUsageExample</span><span class="tok-o">()</span> <span class="tok-o">{</span>
    <span class="tok-n">DmnEngine</span> <span class="tok-n">dmnEngine</span> <span class="tok-o">=</span> <span class="tok-n">flowableDmnRule</span><span class="tok-o">.</span><span class="tok-na">getDmnEngine</span><span class="tok-o">();</span>
    <span class="tok-n">DmnRuleService</span> <span class="tok-n">dmnRuleService</span> <span class="tok-o">=</span> <span class="tok-n">dmnEngine</span><span class="tok-o">.</span><span class="tok-na">getDmnRuleService</span><span class="tok-o">();</span>

    <span class="tok-n">Map</span><span class="tok-o">&lt;</span><span class="tok-n">String</span><span class="tok-o">,</span> <span class="tok-n">Object</span><span class="tok-o">&gt;</span> <span class="tok-n">executionResult</span> <span class="tok-o">=</span> <span class="tok-n">ruleService</span><span class="tok-o">.</span><span class="tok-na">createExecuteDecisionBuilder</span><span class="tok-o">()</span>
            <span class="tok-o">.</span><span class="tok-na">decisionKey</span><span class="tok-o">(</span><span class="tok-s">&quot;extensionUsage&quot;</span><span class="tok-o">)</span>
            <span class="tok-o">.</span><span class="tok-na">variable</span><span class="tok-o">(</span><span class="tok-s">&quot;inputVariable1&quot;</span><span class="tok-o">,</span> <span class="tok-mi">2</span><span class="tok-o">)</span>
            <span class="tok-o">.</span><span class="tok-na">variable</span><span class="tok-o">(</span><span class="tok-s">&quot;inputVariable2&quot;</span><span class="tok-o">,</span> <span class="tok-s">&quot;test2&quot;</span><span class="tok-o">)</span>
            <span class="tok-o">.</span><span class="tok-na">executeWithSingleResult</span><span class="tok-o">();</span>

    <span class="tok-n">Assertions</span><span class="tok-o">.</span><span class="tok-na">assertThat</span><span class="tok-o">(</span><span class="tok-n">executionResult</span><span class="tok-o">).</span><span class="tok-na">containsEntry</span><span class="tok-o">(</span><span class="tok-s">&quot;output1&quot;</span><span class="tok-o">,</span> <span class="tok-s">&quot;test1&quot;</span><span class="tok-o">);</span>
  <span class="tok-o">}</span>
<span class="tok-o">}</span>
</td></tr></table></code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="apiProcessEngineInWebApp">3.5. Web应用程序中的DMN引擎</h3>
<div class="paragraph">
<p>DmnEngine是一个线程安全的类，可以在多个线程之间轻松共享。 在Web应用程序中，这意味着可以在容器启动时创建DMN引擎，并在容器停机时关闭引擎。</p>
</div>
<div class="paragraph">
<p>以下代码片段显示了如何编写一个简单的 ServletContextListener 来初始化和销毁​​普通Servlet环境中的流程引擎：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11</div></td><td class="code"><span></span><span class="tok-kd">public</span> <span class="tok-kd">class</span> <span class="tok-nc">DmnEnginesServletContextListener</span> <span class="tok-kd">implements</span> <span class="tok-n">ServletContextListener</span> <span class="tok-o">{</span>

  <span class="tok-kd">public</span> <span class="tok-kt">void</span> <span class="tok-nf">contextInitialized</span><span class="tok-o">(</span><span class="tok-n">ServletContextEvent</span> <span class="tok-n">servletContextEvent</span><span class="tok-o">)</span> <span class="tok-o">{</span>
    <span class="tok-n">DmnEngines</span><span class="tok-o">.</span><span class="tok-na">init</span><span class="tok-o">();</span>
  <span class="tok-o">}</span>

  <span class="tok-kd">public</span> <span class="tok-kt">void</span> <span class="tok-nf">contextDestroyed</span><span class="tok-o">(</span><span class="tok-n">ServletContextEvent</span> <span class="tok-n">servletContextEvent</span><span class="tok-o">)</span> <span class="tok-o">{</span>
    <span class="tok-n">DmnEngines</span><span class="tok-o">.</span><span class="tok-na">destroy</span><span class="tok-o">();</span>
  <span class="tok-o">}</span>

<span class="tok-o">}</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>contextInitialized 方法将调用 DmnEngines.init()。 这将寻找类路径上的 <code>flowable.dmn.cfg.xml</code> 资源文件，并对于给定的配置创建一个 <code>DmnEngine</code> (例如，带有配置文件的多个JAR).如果类路径上有多个此类资源文件，请确保它们都具有不同的名称。 当需要DMN引擎时，可以使用以下方式获取它：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1</div></td><td class="code"><span></span><span class="tok-n">DmnEngines</span><span class="tok-o">.</span><span class="tok-na">getDefaultDmnEngine</span><span class="tok-o">()</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>或者:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1</div></td><td class="code"><span></span><span class="tok-n">DmnEngines</span><span class="tok-o">.</span><span class="tok-na">getDmnEngine</span><span class="tok-o">(</span><span class="tok-s">&quot;myName&quot;</span><span class="tok-o">);</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>当然，也可以使用任何创建DMN引擎的变体，如<a href="#configuration">configuration section</a>中描述的那样。</p>
</div>
<div class="paragraph">
<p>context-listener的 contextDestroyed方法会调用 DmnEngines.destroy()。 它会妥善关闭所有初始化的DMN引擎。</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="springintegration">4. Spring集成</h2>
<div class="sectionbody">
<div class="paragraph">
<p>虽然我们可以在没有Spring的情况下使用 Flowable DMN，但我们还是有必要提供了一些非常好的集成特性，本章我们将对此进行说明。</p>
</div>
<div class="sect2">
<h3 id="_dmnenginefactorybean">4.1. DmnEngineFactoryBean</h3>
<div class="paragraph">
<p>我们可以将<code>DMN引擎</code>配置为普通的Spring Bean。配置的入口是<code>org.flowable.dmn.spring.DmnEngineFactoryBean</code>类。这个bean采用DMN引擎配置并同时创建DMN引擎。 这意味着Spring属性的创建和配置与<a href="#configuration">configuration章节</a>中记录的是一致的。Spring集成所用的配置与引擎Bean如下所示：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4
5
6
7</div></td><td class="code"><span></span><span class="tok-nt">&lt;bean</span> <span class="tok-na">id=</span><span class="tok-s">&quot;dmnEngineConfiguration&quot;</span> <span class="tok-na">class=</span><span class="tok-s">&quot;org.flowable.dmn.spring.SpringDmnEngineConfiguration&quot;</span><span class="tok-nt">&gt;</span>
    ...
<span class="tok-nt">&lt;/bean&gt;</span>

<span class="tok-nt">&lt;bean</span> <span class="tok-na">id=</span><span class="tok-s">&quot;dmnEngine&quot;</span> <span class="tok-na">class=</span><span class="tok-s">&quot;org.flowable.dmn.spring.DmnEngineFactoryBean&quot;</span><span class="tok-nt">&gt;</span>
  <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;dmnEngineConfiguration&quot;</span> <span class="tok-na">ref=</span><span class="tok-s">&quot;dmnEngineConfiguration&quot;</span> <span class="tok-nt">/&gt;</span>
<span class="tok-nt">&lt;/bean&gt;</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>注意：DmnEngine Bean的配置现在使用的是<code>org.flowable.dmn.spring.SpringDmnEngineConfiguration</code>类。</p>
</div>
</div>
<div class="sect2">
<h3 id="_自动资源部署">4.2. 自动资源部署</h3>
<div class="paragraph">
<p>Spring集成还有一个自动部署资源的特殊功能。在DMN引擎配置中，我们可以指定一组资源。一旦创建DMN引擎，所有指定的资源都会被扫描和部署。适当的过滤可以防止重复的部署。只有当资源确实发生变化时，才会重新部署至Flowable DMN数据库中。这在Spring容器经常重启（例如：测试）的时候非常有用。</p>
</div>
<div class="paragraph">
<p>以下是一个例子：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4
5
6
7
8
9</div></td><td class="code"><span></span><span class="tok-nt">&lt;bean</span> <span class="tok-na">id=</span><span class="tok-s">&quot;dmnEngineConfiguration&quot;</span> <span class="tok-na">class=</span><span class="tok-s">&quot;org.flowable.spring.SpringDmnEngineConfiguration&quot;</span><span class="tok-nt">&gt;</span>
  ...
  <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;deploymentResources&quot;</span>
    <span class="tok-na">value=</span><span class="tok-s">&quot;classpath*:/org/flowable/spring/test/autodeployment/autodeploy/decision*.dmn&quot;</span> <span class="tok-nt">/&gt;</span>
<span class="tok-nt">&lt;/bean&gt;</span>

<span class="tok-nt">&lt;bean</span> <span class="tok-na">id=</span><span class="tok-s">&quot;dmnEngine&quot;</span> <span class="tok-na">class=</span><span class="tok-s">&quot;org.flowable.dmn.spring.DmnEngineFactoryBean&quot;</span><span class="tok-nt">&gt;</span>
  <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;dmnEngineConfiguration&quot;</span> <span class="tok-na">ref=</span><span class="tok-s">&quot;dmnEngineConfiguration&quot;</span> <span class="tok-nt">/&gt;</span>
<span class="tok-nt">&lt;/bean&gt;</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>默认情况下，上面的配置方式会将符合这个过滤器的所有资源组织在一起，作为Flowable DMN引擎的一个部署。为避免未改变资源导致重复部署，重复检测过滤将作用于整个部署操作。有时候，这并不是你想要的。例如，如果我们以这种方式部署了一组DMN资源，即使这些资源中只有的一个DMN流程定义发生了改变，整个部署都被视为新的部署，这个部署中的所有流程定义都将被重新部署，这将导致每个流程定义都会刷新版本，即使实际上只有一个流程定义发生了变化。</p>
</div>
<div class="paragraph">
<p>要想定制部署的方式，我们可以在<code>SpringProcessEngineConfiguration</code>中指定一个额外属性<code>deploymentMode</code>，这个属性定义了部署一组符合过滤器的资源的策略。这个属性默认支持3个值：</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>default</code>: 将所有资源组织在一个部署中，整体用于重复检测过滤。这是默认值，在不指定属性值的时候也使用这个。</p>
</li>
<li>
<p><code>single-resource</code>: 为每个资源创建一个单独的部署，并用于重复检测过滤。如果希望单独部署每一个DMN流程定义，并且只有在它发生变化时才创建新的DMN流程定义版本，就应该使用这个值。</p>
</li>
<li>
<p><code>resource-parent-folder</code>: 为同一个目录下的资源创建一个单独的部署，并用于重复检测过滤。这个属性值可以为大多数资源创建独立的部署。同时仍可以通过将部分资源放在同一个目录下，将它们组织在一起。以下是一个将<code>deploymentMode</code>设置为<code>single-resource</code>的例子：</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4
5
6</div></td><td class="code"><span></span><span class="tok-nt">&lt;bean</span> <span class="tok-na">id=</span><span class="tok-s">&quot;dmnEngineConfiguration&quot;</span>
    <span class="tok-na">class=</span><span class="tok-s">&quot;org.flowable.dmn.spring.SpringDmnEngineConfiguration&quot;</span><span class="tok-nt">&gt;</span>
  ...
  <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;deploymentResources&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;classpath*:/flowable/*.dmn&quot;</span> <span class="tok-nt">/&gt;</span>
  <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;deploymentMode&quot;</span> <span class="tok-na">value=</span><span class="tok-s">&quot;single-resource&quot;</span> <span class="tok-nt">/&gt;</span>
<span class="tok-nt">&lt;/bean&gt;</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>除了使用上面列出的<code>deploymentMode</code>几个枚举值之外，我们还可以自定义自动部署的行为。如果是这样做，我们可以创建<code>SpringDmnEngineConfiguration</code>的子类并覆盖<code>getAutoDeploymentStrategy(String deploymentMode)</code>方法。 这个方法用来设置<code>deploymentMode</code>属性值。</p>
</div>
</div>
<div class="sect2">
<h3 id="springUnitTest">4.3. 单元测试</h3>
<div class="paragraph">
<p>集成Spring后，我们可以很轻松使用标准的<a href="#apiUnitTesting">Flowable测试工具</a>测试业务流程。下面的例子我们来展示如何使用典型的Spring单元测试工具测试业务流程：</p>
</div>
<div class="listingblock">
<div class="title">JUnit 5 测试</div>
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23</div></td><td class="code"><span></span><span class="tok-nd">@ExtendWith</span><span class="tok-o">(</span><span class="tok-n">FlowableDmnSpringExtension</span><span class="tok-o">.</span><span class="tok-na">class</span><span class="tok-o">)</span>
<span class="tok-nd">@ExtendWith</span><span class="tok-o">(</span><span class="tok-n">SpringExtension</span><span class="tok-o">.</span><span class="tok-na">class</span><span class="tok-o">)</span>
<span class="tok-nd">@ContextConfiguration</span><span class="tok-o">(</span><span class="tok-n">classes</span> <span class="tok-o">=</span> <span class="tok-n">DmnSpringJunitJupiterTest</span><span class="tok-o">.</span><span class="tok-na">TestConfiguration</span><span class="tok-o">.</span><span class="tok-na">class</span><span class="tok-o">)</span>
<span class="tok-kd">public</span> <span class="tok-kd">class</span> <span class="tok-nc">SpringJunit4Test</span> <span class="tok-o">{</span>

    <span class="tok-nd">@Autowired</span>
    <span class="tok-kd">private</span> <span class="tok-n">DmnEngine</span> <span class="tok-n">dmnEngine</span><span class="tok-o">;</span>

    <span class="tok-nd">@Autowired</span>
    <span class="tok-kd">private</span> <span class="tok-n">DmnRuleService</span> <span class="tok-n">ruleService</span><span class="tok-o">;</span>

    <span class="tok-nd">@Test</span>
    <span class="tok-nd">@DmnDeploymentAnnotation</span>
    <span class="tok-kd">public</span> <span class="tok-kt">void</span> <span class="tok-nf">simpleDecisionTest</span><span class="tok-o">()</span> <span class="tok-o">{</span>
        <span class="tok-n">Map</span><span class="tok-o">&lt;</span><span class="tok-n">String</span><span class="tok-o">,</span> <span class="tok-n">Object</span><span class="tok-o">&gt;</span> <span class="tok-n">executionResult</span> <span class="tok-o">=</span> <span class="tok-n">ruleService</span><span class="tok-o">.</span><span class="tok-na">createExecuteDecisionBuilder</span><span class="tok-o">()</span>
            <span class="tok-o">.</span><span class="tok-na">decisionKey</span><span class="tok-o">(</span><span class="tok-s">&quot;extensionUsage&quot;</span><span class="tok-o">)</span>
            <span class="tok-o">.</span><span class="tok-na">variable</span><span class="tok-o">(</span><span class="tok-s">&quot;inputVariable1&quot;</span><span class="tok-o">,</span> <span class="tok-mi">2</span><span class="tok-o">)</span>
            <span class="tok-o">.</span><span class="tok-na">variable</span><span class="tok-o">(</span><span class="tok-s">&quot;inputVariable2&quot;</span><span class="tok-o">,</span> <span class="tok-s">&quot;test2&quot;</span><span class="tok-o">)</span>
            <span class="tok-o">.</span><span class="tok-na">executeWithSingleResult</span><span class="tok-o">();</span>

        <span class="tok-n">Assertions</span><span class="tok-o">.</span><span class="tok-na">assertThat</span><span class="tok-o">(</span><span class="tok-n">executionResult</span><span class="tok-o">).</span><span class="tok-na">containsEntry</span><span class="tok-o">(</span><span class="tok-s">&quot;output1&quot;</span><span class="tok-o">,</span> <span class="tok-s">&quot;test1&quot;</span><span class="tok-o">);</span>
    <span class="tok-o">}</span>
<span class="tok-o">}</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="listingblock">
<div class="title">JUnit 4 测试</div>
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26</div></td><td class="code"><span></span><span class="tok-nd">@RunWith</span><span class="tok-o">(</span><span class="tok-n">SpringJUnit4ClassRunner</span><span class="tok-o">.</span><span class="tok-na">class</span><span class="tok-o">)</span>
<span class="tok-nd">@ContextConfiguration</span><span class="tok-o">(</span><span class="tok-s">&quot;classpath:org/flowable/spring/test/junit4/springTypicalUsageTest-context.xml&quot;</span><span class="tok-o">)</span>
<span class="tok-kd">public</span> <span class="tok-kd">class</span> <span class="tok-nc">SpringJunit4Test</span> <span class="tok-o">{</span>

    <span class="tok-nd">@Autowired</span>
    <span class="tok-kd">private</span> <span class="tok-n">DmnEngine</span> <span class="tok-n">dmnEngine</span><span class="tok-o">;</span>

    <span class="tok-nd">@Autowired</span>
    <span class="tok-kd">private</span> <span class="tok-n">DmnRuleService</span> <span class="tok-n">ruleService</span><span class="tok-o">;</span>

    <span class="tok-nd">@Autowired</span>
    <span class="tok-nd">@Rule</span>
    <span class="tok-kd">public</span> <span class="tok-n">FlowableDmnRule</span> <span class="tok-n">flowableSpringRule</span><span class="tok-o">;</span>

    <span class="tok-nd">@Test</span>
    <span class="tok-nd">@DmnDeploymentAnnotation</span>
    <span class="tok-kd">public</span> <span class="tok-kt">void</span> <span class="tok-nf">simpleDecisionTest</span><span class="tok-o">()</span> <span class="tok-o">{</span>
        <span class="tok-n">Map</span><span class="tok-o">&lt;</span><span class="tok-n">String</span><span class="tok-o">,</span> <span class="tok-n">Object</span><span class="tok-o">&gt;</span> <span class="tok-n">executionResult</span> <span class="tok-o">=</span> <span class="tok-n">ruleService</span><span class="tok-o">.</span><span class="tok-na">createExecuteDecisionBuilder</span><span class="tok-o">()</span>
                <span class="tok-o">.</span><span class="tok-na">decisionKey</span><span class="tok-o">(</span><span class="tok-s">&quot;extensionUsage&quot;</span><span class="tok-o">)</span>
                <span class="tok-o">.</span><span class="tok-na">variable</span><span class="tok-o">(</span><span class="tok-s">&quot;inputVariable1&quot;</span><span class="tok-o">,</span> <span class="tok-mi">2</span><span class="tok-o">)</span>
                <span class="tok-o">.</span><span class="tok-na">variable</span><span class="tok-o">(</span><span class="tok-s">&quot;inputVariable2&quot;</span><span class="tok-o">,</span> <span class="tok-s">&quot;test2&quot;</span><span class="tok-o">)</span>
                <span class="tok-o">.</span><span class="tok-na">executeWithSingleResult</span><span class="tok-o">();</span>

        <span class="tok-n">Assertions</span><span class="tok-o">.</span><span class="tok-na">assertThat</span><span class="tok-o">(</span><span class="tok-n">executionResult</span><span class="tok-o">).</span><span class="tok-na">containsEntry</span><span class="tok-o">(</span><span class="tok-s">&quot;output1&quot;</span><span class="tok-o">,</span> <span class="tok-s">&quot;test1&quot;</span><span class="tok-o">);</span>
    <span class="tok-o">}</span>
<span class="tok-o">}</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>注意：这个例子正常运行的条件是，需要在Spring配置中定义一个 <em>org.flowable.dmn.engine.test.FlowableDmnRule</em> Bean（在上面的例子中通过@Autowire自动注入）</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3</div></td><td class="code"><span></span><span class="tok-nt">&lt;bean</span> <span class="tok-na">id=</span><span class="tok-s">&quot;flowableDmnRule&quot;</span> <span class="tok-na">class=</span><span class="tok-s">&quot;org.flowable.dmn.engine.test.FlowableDmnRule&quot;</span><span class="tok-nt">&gt;</span>
    <span class="tok-nt">&lt;property</span> <span class="tok-na">name=</span><span class="tok-s">&quot;dmnEngine&quot;</span> <span class="tok-na">ref=</span><span class="tok-s">&quot;dmnEngine&quot;</span><span class="tok-nt">/&gt;</span>
<span class="tok-nt">&lt;/bean&gt;</span>
</td></tr></table></code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="chDeployment">5. 部署</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_dmn定义">5.1. DMN定义</h3>
<div class="paragraph">
<p>文件名后缀符合 +.dmn+的文件,可以部署到DMN引擎中。</p>
</div>
<div class="paragraph">
<p>当DMN引擎嵌入到流程引擎中,DMN定义文件可以和其他流程相关资源一起,打包到流程包（business archive BAR）里。流程引擎的部署服务会识别DMN资源,将其引入到DMN引擎中。</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>流程包中包含的自定义表达式函数的Java class文件*不会添加到classpath中*。这些自定义的决策表达式class文件应该添加到DMN引擎的classpath,这样引擎才能发现并使用这些决策表达式。</p>
</div>
</td>
</tr>
</table>
</div>
<div class="sect3">
<h4 id="_dmn定义文件决策_和决策表">5.1.1. DMN定义文件,决策 和决策表</h4>
<div class="paragraph">
<p>一个DMN定义包含(不仅仅是)许多决策。一个决策一个表达式。DMN规范定义(描述)了多种类型的表达式。目前在Flowable DMN中,我们支持决策表类型的表达式。
部署一个DMN定义是,定义中的每个*包含决策表*的决策定义,会分开插入到ACT_DMN_DECISION表里。</p>
</div>
</div>
<div class="sect3">
<h4 id="_编程方式部署">5.1.2. 编程方式部署</h4>
<div class="paragraph">
<p>可以这样部署一个DMN定义:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4
5
6</div></td><td class="code"><span></span><span class="tok-n">String</span> <span class="tok-n">dmnDefinition</span> <span class="tok-o">=</span> <span class="tok-s">&quot;path/to/definition-one.dmn&quot;</span><span class="tok-o">;</span> <span class="tok-c1">//Don&#39;t forget the .dmn extension!</span>

<span class="tok-n">repositoryService</span><span class="tok-o">.</span><span class="tok-na">createDeployment</span><span class="tok-o">()</span>
    <span class="tok-o">.</span><span class="tok-na">name</span><span class="tok-o">(</span><span class="tok-s">&quot;Deployment of DMN definition-one&quot;</span><span class="tok-o">)</span>
    <span class="tok-o">.</span><span class="tok-na">addClasspathResource</span><span class="tok-o">(</span><span class="tok-n">dmnDefinition</span><span class="tok-o">)</span>
    <span class="tok-o">.</span><span class="tok-na">deploy</span><span class="tok-o">();</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>也可以使用诸如`addInputStream`的其他方式部署DMN定义。以下是一个使用外部文件部署DMN定义的例子：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4
5
6</div></td><td class="code"><span></span><span class="tok-n">File</span> <span class="tok-n">dmnFile</span> <span class="tok-o">=</span> <span class="tok-k">new</span> <span class="tok-n">File</span><span class="tok-o">(</span><span class="tok-s">&quot;/path/to/definition-two.dmn&quot;</span><span class="tok-o">);</span> <span class="tok-c1">//Don&#39;t forget the .dmn extension!</span>

<span class="tok-n">repositoryService</span><span class="tok-o">.</span><span class="tok-na">createDeployment</span><span class="tok-o">()</span>
    <span class="tok-o">.</span><span class="tok-na">name</span><span class="tok-o">(</span><span class="tok-s">&quot;Deployment of DMN definition-two&quot;</span><span class="tok-o">)</span>
    <span class="tok-o">.</span><span class="tok-na">addInputStream</span><span class="tok-o">(</span><span class="tok-n">dmnFile</span><span class="tok-o">.</span><span class="tok-na">getName</span><span class="tok-o">(),</span> <span class="tok-k">new</span> <span class="tok-n">FileInputStream</span><span class="tok-o">(</span><span class="tok-n">dmnFile</span><span class="tok-o">))</span>
    <span class="tok-o">.</span><span class="tok-na">deploy</span><span class="tok-o">();</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>部署的文件,名称可以是任意文本,但是作为有效的DMN定义文件,定义文件名后缀应该是(".dmn")。</p>
</div>
</div>
<div class="sect3">
<h4 id="_java_类">5.1.3. Java 类</h4>
<div class="paragraph">
<p>当决策执行时,使用的自定义Java class文件,需要放在引擎的classpath中。</p>
</div>
<div class="paragraph">
<p>在部署DMN定义时,这些class文件可以没有放到引擎的classpath下。</p>
</div>
<div class="paragraph">
<p>在测试时需要添加自定义Java类。需要把包含这些class文件的jar包放到flowable-ui-app或flowable-app-rest工程的lib下(${webserver}/${appname}/WEB-INF/lib/)。千万不要忘记这些依赖。另外,也可以将这些依赖放到tomcat中,<code>${tomcat.home}/lib</code>。</p>
</div>
</div>
<div class="sect3">
<h4 id="_创建单应用">5.1.4. 创建单应用</h4>
<div class="paragraph">
<p>不用确保所有DMN引擎claspath中包含所有代理类,并且使用了正确的spring配置,你可以考虑在自己的webapp里引入flowable-rest,这样就只有一个+Dmn引擎+.</p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="versioningOfDMNDefinitions">5.2. DMB决策版本控制</h3>
<div class="paragraph">
<p>DMN没有版本控制的概念。这实际上很好，因为作为开发项目的一部分，可执行DMN定义文件可能位于版本控制系统存储库（例如Subversion、Git或Mercurial）中。部署期间创建DMN决策的版本。在部署过程中，flowable将为+decision+分配一个版本，然后将其存储在flowable db中。</p>
</div>
<div class="paragraph">
<p>因为DMN定义中的每个DMN决策都是一个DMN定义,将执行以下步骤来初始化属性+key+、<code>version</code>、<code>name+和+id</code>：</p>
</div>
<div class="ulist">
<ul>
<li>
<p>定义文件中 decision <code>id</code> 属性在决策表中是 <code>key</code>.</p>
</li>
<li>
<p>定义文件中 decision <code>name</code> 属性在决策表中是 <code>name</code>.</p>
</li>
<li>
<p>一个有特定的key的决策在首次部署时,版本标记为1。对于之后所有拥有相同key的发布,版本号相对于之前最高版本号+1。所以key属性是用来区分不同的决策。</p>
</li>
<li>
<p>id属性时在集群环境中,保证决策表的唯一的[数字]标识。</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>以下面的流程为例：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4</div></td><td class="code"><span></span><span class="tok-nt">&lt;definitions</span> <span class="tok-na">id=</span><span class="tok-s">&quot;myDefinitions&quot;</span> <span class="tok-nt">&gt;</span>
  <span class="tok-nt">&lt;decision</span> <span class="tok-na">id=</span><span class="tok-s">&quot;myDecision&quot;</span> <span class="tok-na">name=</span><span class="tok-s">&quot;My important decision&quot;</span> <span class="tok-nt">&gt;</span>
    <span class="tok-nt">&lt;decisionTable</span> <span class="tok-na">id=</span><span class="tok-s">&quot;decisionTable1&quot;</span> <span class="tok-na">hitPolicy=</span><span class="tok-s">&quot;FIRST&quot;</span> <span class="tok-nt">&gt;</span>
    ...
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>当部署了该决策,决策表在数据库中是这样的：</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">id</th>
<th class="tableblock halign-left valign-top">key</th>
<th class="tableblock halign-left valign-top">name</th>
<th class="tableblock halign-left valign-top">version</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">e29d4126-ed4d-11e6-9e00-7282cbd6ce64</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">myDecision</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">My important decision</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>当我们再发布这个流程的更新版本（比如：更改了用户任务）,流程定义的<code>id</code> 和之前是一样的。
流程定义表会包含一下信息：</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">id</th>
<th class="tableblock halign-left valign-top">key</th>
<th class="tableblock halign-left valign-top">name</th>
<th class="tableblock halign-left valign-top">version</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">e29d4126-ed4d-11e6-9e00-7282cbd6ce64</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">myDecision</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">My important decision</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">e9c2a6c0-c085-11e6-9096-6ab56fad108a</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">myDecision</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">My important decision</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">2</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>当调用了 <code>dmnRuleService.executeDecisionByKey("myDecision")</code> , 之后会调用版本号 <code>2</code> 的决策定义,因为这个是决策定义的最新版本。</p>
</div>
<div class="paragraph">
<p>如果我们创建第二个决策,定义如下所示,然后发布到flowable DMN中,数据库表中会增加第三行。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4</div></td><td class="code"><span></span><span class="tok-nt">&lt;definitions</span> <span class="tok-na">id=</span><span class="tok-s">&quot;myNewDefinitions&quot;</span> <span class="tok-nt">&gt;</span>
  <span class="tok-nt">&lt;decision</span> <span class="tok-na">id=</span><span class="tok-s">&quot;myNewDecision&quot;</span> <span class="tok-na">name=</span><span class="tok-s">&quot;My important decision&quot;</span> <span class="tok-nt">&gt;</span>
    <span class="tok-nt">&lt;decisionTable</span> <span class="tok-na">id=</span><span class="tok-s">&quot;decisionTable1&quot;</span> <span class="tok-na">hitPolicy=</span><span class="tok-s">&quot;FIRST&quot;</span> <span class="tok-nt">&gt;</span>
      ...
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>表中数据是这样的:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">id</th>
<th class="tableblock halign-left valign-top">key</th>
<th class="tableblock halign-left valign-top">name</th>
<th class="tableblock halign-left valign-top">version</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">e29d4126-ed4d-11e6-9e00-7282cbd6ce64</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">myDecision</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">My important decision</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">e9c2a6c0-c085-11e6-9096-6ab56fad108a</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">myDecision</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">My important decision</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">d317d3f7-e948-11e6-9ce6-b28c070b517d</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">myNewDecision</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">My important decision</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>注意：新的决策的key和第一个决策的key是不一样的。尽管name属性是一样的（正常情况下，表意清晰的话，我们需要把name属性也改掉）,FlowableDMN引擎通过 <code>id</code> 属性来区分不同的决策。新增的决策将会以版本1部署。</p>
</div>
</div>
<div class="sect2">
<h3 id="deploymentCategory">5.3. 分类</h3>
<div class="paragraph">
<p>DMN部署和决策表都可以自定义分类。
DMN部署分类可以这样定义：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4
5</div></td><td class="code"><span></span><span class="tok-n">dmnRepository</span>
    <span class="tok-o">.</span><span class="tok-na">createDeployment</span><span class="tok-o">()</span>
    <span class="tok-o">.</span><span class="tok-na">category</span><span class="tok-o">(</span><span class="tok-s">&quot;yourCategory&quot;</span><span class="tok-o">)</span>
    <span class="tok-o">...</span>
    <span class="tok-o">.</span><span class="tok-na">deploy</span><span class="tok-o">();</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="paragraph">
<p>决策表分类可以这样定义：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="java"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1</div></td><td class="code"><span></span><span class="tok-n">dmnRepository</span><span class="tok-o">.</span><span class="tok-na">setDecisionTableCategory</span><span class="tok-o">(</span><span class="tok-s">&quot;e9c2a6c0-c085-11e6-9096-6ab56fad108a&quot;</span><span class="tok-o">,</span> <span class="tok-s">&quot;yourCategory&quot;</span><span class="tok-o">);</span>
</td></tr></table></code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="bpmn20">6. DMN 1.1 入门</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="whatIsDmn">6.1. 什么是DMN？</h3>
<div class="paragraph">
<p>Decision Model &amp; Notation(DMN)是由<a href="http://www.omg.org/spec/DMN/1.1">对象管理组（OMG）</a>发布的标准。它是描述和构建组织内可重复决策的标准方法，以确保决策模型在各组织之间是通用的。</p>
</div>
</div>
<div class="sect2">
<h3 id="dmnDefiningDecision">6.2. 什么是DMN定义？</h3>
<div class="paragraph">
<p>DMN 1.1模式的根元素是<strong>definitions</strong>。在这个项目中可以定义多个决策定义(尽管我们建议每个文件中只有一个决策定义，这可以简化开发过程的后期维护)。每个决策可以定义一个表达式。目前，Flowable支持几种表达式类型中的<strong>决策表</strong>。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13</div></td><td class="code"><span></span><span class="tok-nt">&lt;definitions</span> <span class="tok-na">xmlns=</span><span class="tok-s">&quot;http://www.omg.org/spec/DMN/20151101&quot;</span>
  <span class="tok-na">namespace=</span><span class="tok-s">&quot;http://www.flowable.org/dmn&quot;</span>
  <span class="tok-na">name=</span><span class="tok-s">&quot;DetermineDiscount&quot;</span><span class="tok-nt">&gt;</span>

  <span class="tok-nt">&lt;decision</span> <span class="tok-na">id=</span><span class="tok-s">&quot;DET_DISC_1&quot;</span> <span class="tok-na">name=</span><span class="tok-s">&quot;DetermineDiscount&quot;</span><span class="tok-nt">&gt;</span>

    <span class="tok-nt">&lt;decisionTable</span> <span class="tok-na">id=</span><span class="tok-s">&quot;determineDiscountTable1&quot;</span> <span class="tok-na">hitPolicy=</span><span class="tok-s">&quot;FIRST&quot;</span><span class="tok-nt">&gt;</span>
      ..
    <span class="tok-nt">&lt;/decisionTable&gt;</span>

  <span class="tok-nt">&lt;/decision&gt;</span>

<span class="tok-nt">&lt;/definitions&gt;</span>
</td></tr></table></code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_创建dmn定义">6.3. 创建DMN定义</h3>
<div class="paragraph">
<p>虽然使用纯文本编辑器创建DMN定义是可行的，但是对于此示例，我们将首先使用Flowable建模器的决策表编辑器。</p>
</div>
<div class="paragraph">
<p>接下来，我们将实现一个非常简单的用例：根据客户类别确定折扣百分比。</p>
</div>
<div class="paragraph">
<p>首先打开Flowable建模器中的决策表部分。</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="images/decision_tables_1.png" alt="decision tables 1">
</div>
</div>
<div class="paragraph">
<p>选择<strong>Create Decision Table</strong>。</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="images/decision_tables_2.png" alt="decision tables 2">
</div>
</div>
<div class="paragraph">
<p>填写决策表名称和决策表唯一键，然后选择<strong>Create new decision table</strong>。</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="images/decision_tables_3.png" alt="decision tables 3">
</div>
</div>
<div class="paragraph">
<p>现在就可以定义决策表了。接下来我们对编辑器做个说明。</p>
</div>
<div class="sect3">
<h4 id="_hit_policy_命中策略">6.3.1. Hit Policy 命中策略</h4>
<div class="paragraph">
<p>我们可以在左上角选择<strong>hit policy</strong>。</p>
</div>
<div class="paragraph">
<p>可以看到，有7个命中策略可用。</p>
</div>
<div class="paragraph">
<p><strong>单一命中</strong></p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>F</strong>IRST: 可以匹配多个（重叠）具有不同输出条目的规则。返回规则顺序中的第一次命中（返回后停止评估）。</p>
</li>
<li>
<p><strong>U</strong>NIQUE: 没有重叠的可能，所有规则都是互斥的。只能匹配到一条规则。</p>
</li>
<li>
<p><strong>A</strong>NY: 可能会有重叠，但如果所有匹配规则显示每个输出的输出条目相等，就可以使用任何匹配。如果输出条目不相等，则命中策略不正确，结果将为空并标记为failed。当禁用<a href="#strictMode">strict mode</a>时，结果是最后一个有效规则。(违规将以验证消息的形式出现)</p>
</li>
<li>
<p><strong>P</strong>RIORITY: 具有不同的输出条目的多个规则可以匹配。此策略返回具有最高输出优先级的匹配规则。输出优先级在输出值的有序列表中按优先级递减的顺序指定。当禁用<a href="#strictMode">strict mode</a>且未定义输出值时，结果是最后一个有效规则。(违规将以验证消息的形式出现)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><strong>多重命中</strong></p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>O</strong>UTPUT ORDER: 按输出优先级递减的顺序返回所有命中规则。输出优先级在输出值的有序列表中按优先级递减的顺序指定。</p>
</li>
<li>
<p><strong>R</strong>ULE ORDER: 按规则顺序返回所有命中。</p>
</li>
<li>
<p><strong>C</strong>OLLECT: 以任意顺序返回所有命中。我们可以添加运算符（<em>+</em>，<em>&lt;</em>，<em>&gt;</em>，<em>＃</em>）来将一个简单函数应用于输出。如果没有运算符，则结果是所有输出条目的列表。</p>
<div class="ulist">
<ul>
<li>
<p>+ (sum): 决策表的结果是所有不同输出的总和。</p>
</li>
<li>
<p>&lt; (min): 决策表的结果是所有输出的最小值。</p>
</li>
<li>
<p>&gt; (max): 决策表的结果是所有输出的最大值。</p>
</li>
<li>
<p># (count): 决策表的结果是所有不同输出的总数。</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
<div class="sect3">
<h4 id="_输入和输出表达式">6.3.2. 输入和输出表达式</h4>
<div class="paragraph">
<p>决策表本身的表头分为两部分;蓝色和绿色。蓝色部分是<strong>input expressions</strong>（输入表达式）;绿色的是<strong>output expressions</strong>（输出表达式）。</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="images/decision_tables_4.png" alt="decision tables 4">
</div>
</div>
<div class="paragraph">
<p>在输入表达式中，我们可以定义将在规则输入条目的表达式中使用的变量(下面解释)。还可以通过选择<strong>Add Input</strong>(右键单击option菜单或单击plus图标)来定义多个输入表达式。</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="images/decision_tables_5.png" alt="decision tables 5">
</div>
</div>
<div class="paragraph">
<p>在输出表达式中，我们可以定义将创建什么变量来构成决策表执行的结果(变量的值将由输出条目表达式决定，下面解释)。还可以通过选择<strong>Add Output</strong>(右键单击option菜单或单击plus图标)来定义多个输出表达式。</p>
</div>
</div>
<div class="sect3">
<h4 id="_规则">6.3.3. 规则</h4>
<div class="paragraph">
<p>每个规则由一个或多个输入项和一个或多个输出项组成。输入项是一个表达式，它将根据输入的变量(该“列”的值)求值。当所有输入项都为true时，就认为整个规则是true，开始计算输出项。</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>DMN规范定义了一种表达式语言：(S)-FEEL。目前，我们不支持这部分规范。 在Flowable DMN中，我们使用JUEL作为表达式语言。</p>
</div>
</td>
</tr>
</table>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="images/decision_tables_6.png" alt="decision tables 6">
</div>
</div>
<div class="paragraph">
<p>我们可以双击相应的单元格输入表达式。在此示例中，输入表达式== BRONZE。结合相应输入表达式（列标题）中定义的变量，将在运行时生成完整的表达式customerCat == "BRONZE"。</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="images/decision_tables_7.png" alt="decision tables 7">
</div>
</div>
<div class="paragraph">
<p>然后双击相应的单元格输出表达式。这实际上更像是一个隐式赋值。
在此示例中，输入表达式5。</p>
</div>
<div class="paragraph">
<p>然后，我们可以通过添加更多规则（通过选择添加规则）继续完成决策表。</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="images/decision_tables_8.png" alt="decision tables 8">
</div>
</div>
<div class="paragraph">
<p>在我们的示例中，规则4有一个空的输入条目，引擎将会把这个空输入条目评估为true。那么如果其他规则都无效，则规则4的结果将是该决策表的输出。在这种情况下，变量<strong>discountPerc</strong>的值为<strong>0</strong>。</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="images/decision_tables_9.png" alt="decision tables 9">
</div>
</div>
<div class="paragraph">
<p>现在我们可以保存决策表。填入决策表唯一键。</p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_bpmn2_0流程中的应用">6.4. BPMN2.0流程中的应用</h3>
<div class="paragraph">
<p>通过包含<strong>Decision task</strong>并选择<strong>Decision table reference</strong>，可以在BPMN2.0流程中使用新创建的决策表。</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="images/decision_tables_10.png" alt="decision tables 10">
</div>
</div>
<div class="paragraph">
<p>上面定义的流程中，该流程有一个启动表单，它将<strong>customer category</strong>（客户类别）提供给流程实例（从而提供给决策表）。<strong>Display Discount</strong>（显示折扣）用户任务使用表达式表单字段显示决策表的结果;${discountperc}。</p>
</div>
</div>
<div class="sect2">
<h3 id="_dmn_1_1_xml文件">6.5. DMN 1.1 xml文件</h3>
<div class="paragraph">
<p>上面示例的完整DMN 1.1 xml文件。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="xml"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51</div></td><td class="code"><span></span><span class="tok-nt">&lt;definitions</span> <span class="tok-na">xmlns=</span><span class="tok-s">&quot;http://www.omg.org/spec/DMN/20151101&quot;</span> <span class="tok-na">id=</span><span class="tok-s">&quot;definition_78d09dd7-374c-11e8-b5d8-0242ac120005&quot;</span> <span class="tok-na">name=</span><span class="tok-s">&quot;Determine Discount&quot;</span> <span class="tok-na">namespace=</span><span class="tok-s">&quot;http://www.flowable.org/dmn&quot;</span><span class="tok-nt">&gt;</span>
  <span class="tok-nt">&lt;decision</span> <span class="tok-na">id=</span><span class="tok-s">&quot;DET_DISC_1&quot;</span> <span class="tok-na">name=</span><span class="tok-s">&quot;Determine Discount&quot;</span><span class="tok-nt">&gt;</span>
    <span class="tok-nt">&lt;decisionTable</span> <span class="tok-na">id=</span><span class="tok-s">&quot;decisionTable_78d09dd7-374c-11e8-b5d8-0242ac120005&quot;</span> <span class="tok-na">hitPolicy=</span><span class="tok-s">&quot;UNIQUE&quot;</span><span class="tok-nt">&gt;</span>
      <span class="tok-nt">&lt;input</span> <span class="tok-na">label=</span><span class="tok-s">&quot;Customer Category&quot;</span><span class="tok-nt">&gt;</span>
        <span class="tok-nt">&lt;inputExpression</span> <span class="tok-na">id=</span><span class="tok-s">&quot;inputExpression_1&quot;</span> <span class="tok-na">typeRef=</span><span class="tok-s">&quot;string&quot;</span><span class="tok-nt">&gt;</span>
          <span class="tok-nt">&lt;text&gt;</span>customerCat<span class="tok-nt">&lt;/text&gt;</span>
        <span class="tok-nt">&lt;/inputExpression&gt;</span>
        <span class="tok-nt">&lt;inputValues&gt;</span>
          <span class="tok-nt">&lt;text&gt;</span>&quot;BRONZE&quot;,&quot;SILVER&quot;,&quot;GOLD&quot;<span class="tok-nt">&lt;/text&gt;</span>
        <span class="tok-nt">&lt;/inputValues&gt;</span>
      <span class="tok-nt">&lt;/input&gt;</span>
      <span class="tok-nt">&lt;output</span> <span class="tok-na">id=</span><span class="tok-s">&quot;outputExpression_2&quot;</span> <span class="tok-na">label=</span><span class="tok-s">&quot;Discount Percentage&quot;</span> <span class="tok-na">name=</span><span class="tok-s">&quot;discountPerc&quot;</span> <span class="tok-na">typeRef=</span><span class="tok-s">&quot;number&quot;</span><span class="tok-nt">&gt;</span>
        <span class="tok-nt">&lt;outputValues&gt;</span>
          <span class="tok-nt">&lt;text&gt;</span>&quot;0&quot;,&quot;5&quot;,&quot;10&quot;,&quot;20&quot;<span class="tok-nt">&lt;/text&gt;</span>
        <span class="tok-nt">&lt;/outputValues&gt;</span>
      <span class="tok-nt">&lt;/output&gt;</span>
      <span class="tok-nt">&lt;rule&gt;</span>
        <span class="tok-nt">&lt;inputEntry</span> <span class="tok-na">id=</span><span class="tok-s">&quot;inputEntry_1_1&quot;</span><span class="tok-nt">&gt;</span>
          <span class="tok-nt">&lt;text&gt;</span><span class="tok-cp">&lt;![CDATA[== &quot;BRONZE&quot;]]&gt;</span><span class="tok-nt">&lt;/text&gt;</span>
        <span class="tok-nt">&lt;/inputEntry&gt;</span>
        <span class="tok-nt">&lt;outputEntry</span> <span class="tok-na">id=</span><span class="tok-s">&quot;outputEntry_2_1&quot;</span><span class="tok-nt">&gt;</span>
          <span class="tok-nt">&lt;text&gt;</span><span class="tok-cp">&lt;![CDATA[5]]&gt;</span><span class="tok-nt">&lt;/text&gt;</span>
        <span class="tok-nt">&lt;/outputEntry&gt;</span>
      <span class="tok-nt">&lt;/rule&gt;</span>
      <span class="tok-nt">&lt;rule&gt;</span>
        <span class="tok-nt">&lt;inputEntry</span> <span class="tok-na">id=</span><span class="tok-s">&quot;inputEntry_1_2&quot;</span><span class="tok-nt">&gt;</span>
          <span class="tok-nt">&lt;text&gt;</span><span class="tok-cp">&lt;![CDATA[== &quot;SILVER&quot;]]&gt;</span><span class="tok-nt">&lt;/text&gt;</span>
        <span class="tok-nt">&lt;/inputEntry&gt;</span>
        <span class="tok-nt">&lt;outputEntry</span> <span class="tok-na">id=</span><span class="tok-s">&quot;outputEntry_2_2&quot;</span><span class="tok-nt">&gt;</span>
          <span class="tok-nt">&lt;text&gt;</span><span class="tok-cp">&lt;![CDATA[10]]&gt;</span><span class="tok-nt">&lt;/text&gt;</span>
        <span class="tok-nt">&lt;/outputEntry&gt;</span>
      <span class="tok-nt">&lt;/rule&gt;</span>
      <span class="tok-nt">&lt;rule&gt;</span>
        <span class="tok-nt">&lt;inputEntry</span> <span class="tok-na">id=</span><span class="tok-s">&quot;inputEntry_1_3&quot;</span><span class="tok-nt">&gt;</span>
          <span class="tok-nt">&lt;text&gt;</span><span class="tok-cp">&lt;![CDATA[== &quot;GOLD&quot;]]&gt;</span><span class="tok-nt">&lt;/text&gt;</span>
        <span class="tok-nt">&lt;/inputEntry&gt;</span>
        <span class="tok-nt">&lt;outputEntry</span> <span class="tok-na">id=</span><span class="tok-s">&quot;outputEntry_2_3&quot;</span><span class="tok-nt">&gt;</span>
          <span class="tok-nt">&lt;text&gt;</span><span class="tok-cp">&lt;![CDATA[20]]&gt;</span><span class="tok-nt">&lt;/text&gt;</span>
        <span class="tok-nt">&lt;/outputEntry&gt;</span>
      <span class="tok-nt">&lt;/rule&gt;</span>
      <span class="tok-nt">&lt;rule&gt;</span>
        <span class="tok-nt">&lt;inputEntry</span> <span class="tok-na">id=</span><span class="tok-s">&quot;inputEntry_1_4&quot;</span><span class="tok-nt">&gt;</span>
          <span class="tok-nt">&lt;text&gt;</span><span class="tok-cp">&lt;![CDATA[-]]&gt;</span><span class="tok-nt">&lt;/text&gt;</span>
        <span class="tok-nt">&lt;/inputEntry&gt;</span>
        <span class="tok-nt">&lt;outputEntry</span> <span class="tok-na">id=</span><span class="tok-s">&quot;outputEntry_2_4&quot;</span><span class="tok-nt">&gt;</span>
          <span class="tok-nt">&lt;text&gt;</span><span class="tok-cp">&lt;![CDATA[0]]&gt;</span><span class="tok-nt">&lt;/text&gt;</span>
        <span class="tok-nt">&lt;/outputEntry&gt;</span>
      <span class="tok-nt">&lt;/rule&gt;</span>
    <span class="tok-nt">&lt;/decisionTable&gt;</span>
  <span class="tok-nt">&lt;/decision&gt;</span>
<span class="tok-nt">&lt;/definitions&gt;</span>
</td></tr></table></code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>此处需要重点强调的是，在Flowable中使用的决策表键是DMN xml文件中的决策ID。</p>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="restApiChapter">7. DMN REST API</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_general_flowable_rest_principles">7.1. Flowable REST一般原则</h3>
<div class="sect3">
<h4 id="_installation_and_authentication">7.1.1. 安装与认证</h4>
<div class="paragraph">
<p>Flowable为Flowable引擎提供了REST API，可以通过在servlet容器（如Apache Tomcat）中部署flowable-rest.war文件来安装。另外，也可以通过在应用中引入servlet（包括对应的映射），并将所有flowable-rest的依赖加入classpath的方式使用。</p>
</div>
<div class="paragraph">
<p>默认情况下Flowable引擎会连接至一个H2内存数据库。可以通过<em>WEB-INF/META-INF/flowable-app</em>文件夹下的flowable-app.properties文件修改数据库设置。REST API使用JSON格式( <a href="http://www.json.org" class="bare">http://www.json.org</a> )，并基于Spring MVC( <a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/html/mvc.html" class="bare">http://docs.spring.io/spring/docs/current/spring-framework-reference/html/mvc.html</a> )构建。</p>
</div>
<div class="paragraph">
<p>默认情况下访问任何REST资源都需要具有<em>rest-access-api</em>权限的合法用户。如果需要任何合法用户都可以访问REST API，可以将<em>flowable.rest.app.authentication-mode</em>设置为<em>any-user</em>（这也是之前版本Flowable的默认设置）。</p>
</div>
<div class="paragraph">
<p>通过如下参数设置可以访问REST API的默认用户：</p>
</div>
<div class="listingblock">
<div class="content">
<pre>flowable.rest.app.admin.user-id=rest-admin
flowable.rest.app.admin.password=test
flowable.rest.app.admin.first-name=Rest
flowable.rest.app.admin.last-name=Admin</pre>
</div>
</div>
<div class="paragraph">
<p>当REST应用启动时，如果用户不存在或无法找到，则会创建该用户。这个用户会被赋予访问REST API所需的<em>access-rest-api</em>权限。<strong>请不要忘记修改这个用户的密码</strong>。如果未设置<em>flowable.rest.app.admin.user-id</em>，则不会创建用户或权限。也因为此，在初始化完成后删除这些参数，并不会删除之前已经配置的用户或权限。</p>
</div>
<div class="paragraph">
<p>使用基础HTTP访问认证，因此在请求时，需要在HTTP-header中添加 <em>Authorization: Basic &#8230;&#8203;==</em> 。也可以在请求url中包含用户名与密码（如 <em><a href="http://username:password@localhost:8080/xyz" class="bare">http://username:password@localhost:8080/xyz</a></em>）。</p>
</div>
<div class="paragraph">
<p><strong>建议使用基础认证时，同时使用HTTPS。</strong></p>
</div>
</div>
<div class="sect3">
<h4 id="_configuration_2">7.1.2. 配置</h4>
<div class="paragraph">
<p>Flowable REST web应用使用Spring Java Configuration来启动Flowable引擎，使用Spring security定义基础认证安全，并为为特定的变量处理定义了变量转换。
有少量参数可以通过修改WEB-INF/classes文件夹下的engine.properties文件定义。
如果需要高级配置选项，可以在flowable-custom-context.xml文件中覆盖默认的Spring bean，这个文件也在WEB-INF/classes文件夹下。
该文件中已经以注释形式提供了示例配置。也可以在该文件中定义一个新的命名为restResponsefactory的Spring bean，覆盖默认的RestResponseFactory，并使用自定义实现类。</p>
</div>
</div>
<div class="sect3">
<h4 id="restUsageInTomcat">7.1.3. 在Tomcat中使用</h4>
<div class="paragraph">
<p>由于<a href="http://tomcat.apache.org/tomcat-8.0-doc/security-howto.html">Tomcat中的默认安全参数</a>，<strong>默认不能使用转义斜线符（<code>%2F</code>与<code>%5C</code>）（将返回400）。</strong>这可能会影响部署资源与其数据URL，因为URL可能包含转义斜线符。</p>
</div>
<div class="paragraph">
<p>当发现400异常结果时，可以设置下列系统参数:</p>
</div>
<div class="paragraph">
<p><em>-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true</em></p>
</div>
<div class="paragraph">
<p>最佳实践是（在post/put JSON时），在下面介绍的HTTP请求中，永远将<strong>Accept</strong>与<strong>Content-Type</strong>HTTP头设置为<strong>application/json</strong>。</p>
</div>
</div>
<div class="sect3">
<h4 id="_methods_and_return_codes">7.1.4. 方法与返回码</h4>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 1. HTTP方法与对应操作</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">方法</th>
<th class="tableblock halign-left valign-top">操作</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>GET</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">获取单个资源，或获取一组资源。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>POST</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">创建一个新资源。在查询结构太复杂，不能放入GET请求的查询URL中时，也用于执行资源查询。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>PUT</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">更新一个已有资源的参数。也用于调用已有资源提供的操作。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>DELETE</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">删除一个已有资源。</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 2. HTTP方法响应码</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">响应</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>200 - Ok</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">操作成功，返回响应（<code>GET</code>与<code>PUT</code>请求）。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>201 - 已创建</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">操作成功，已经创建了实体，并在响应体中返回（<code>POST</code>请求）。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>204 - 无内容</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">操作成功，已经删除了实体，因此没有返回的响应体（<code>DELETE</code>请求）。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>401 - 未认证</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">操作失败。操作要求设置认证头。如果请求中有认证头，则提供的鉴证并不合法，或者用户未被授权进行该操作。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>403 - 禁止</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">操作被禁止，且不应重试。这不是鉴证或授权的问题，而是说明不允许该操作。例如：无论任何用户或流程/任务的状态，删除一个运行中流程的任务是且永远是不允许的。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>404 - 未找到</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">操作失败。请求的资源未找到。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>405 - 不允许的方法</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">操作失败。使用的方法不能用于该资源。例如，更新（PUT）部署资源将返回<code>405</code>响应码。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>409 - 冲突</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">操作失败。该操作导致更新一个已被其他操作更新的资源，因此本更新不再有效。也可以表示正在为一个集合创建一个资源，但该标识符已存在。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>415 - 不支持的媒体类型</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">操作失败。请求提包含了不支持的媒体类型。也会发生在请求体JSON中包含了未知的属性或值，但没有可用的格式/类型来处理的情况。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>500 - 服务器内部错误</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">操作失败。执行操作时发生了未知异常。响应体中包含了错误的细节。</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>HTTP响应的media-type总是<code>application/json</code>，除非请求的是二进制内容（例如部署资源数据）。这时将使用内容的media-type。</p>
</div>
</div>
<div class="sect3">
<h4 id="_error_response_body">7.1.5. 错误响应体</h4>
<div class="paragraph">
<p>当发生错误时（可能是客户端或服务器端的错误，4XX及5XX状态码），响应体会包含一个描述了发生的错误的对象。任务未找到时的404状态的例子：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="json"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4</div></td><td class="code"><span></span><span class="tok-p">{</span>
  <span class="tok-nt">&quot;statusCode&quot;</span> <span class="tok-p">:</span> <span class="tok-mi">404</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;errorMessage&quot;</span> <span class="tok-p">:</span> <span class="tok-s2">&quot;Could not find a task with id &#39;444&#39;.&quot;</span>
<span class="tok-p">}</span>
</td></tr></table></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_request_parameters">7.1.6. 请求参数</h4>
<div class="sect4">
<h5 id="_url_fragments">URL片段</h5>
<div class="paragraph">
<p>作为url的一部分的参数（例如，<code><a href="http://host/flowable-rest/service/repository/deployments/{deploymentId}" class="bare">http://host/flowable-rest/service/repository/deployments/{deploymentId}</a></code>中的deploymentId参数），如果包含特殊字符，则需要进行合适的转义（参见<a href="https://en.wikipedia.org/wiki/Percent-encoding">URL编码或百分号编码</a>）。大多数框架都内建了这个功能，但要记得考虑它。特别是对可能包含斜线符的段落（例如部署资源），就必须要做转义。</p>
</div>
</div>
<div class="sect4">
<h5 id="_rest_url_query_parameters">Rest URL查询参数</h5>
<div class="paragraph">
<p>作为查询字符串添加在URL中的参数（例如<code><a href="http://host/flowable-rest/service/deployments?name=Deployment" class="bare">http://host/flowable-rest/service/deployments?name=Deployment</a></code>中的name参数）可以使用下列类型。在相应的REST-API文档中也会提到：</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 3. URL查询参数类型</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">类型</th>
<th class="tableblock halign-left valign-top">格式</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">纯文本参数。可以包含任何URL允许的合法字符。对于<code>XXXLike</code>参数，字符串可能会包含通配符<code>%</code>（需要进行URL编码）。可以进行like搜索，例如，'Tas%'将匹配所有以&#8217;Tas&#8217;开头的值。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Integer</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">整形参数。只能包含数字型非小数值，在-2.147.483.648至2.147.483.647之间。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Long</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">长整形参数。只能包含数字型非小数值，在-9.223.372.036.854.775.808至9.223.372.036.854.775.807之间。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">boolean型参数。可以为<code>true</code>或<code>false</code>。任何其他值都会导致'<code>405 - 错误请求</code>'响应码。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Date</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">日期型参数。使用ISO-8601日期格式（参考<a href="http://en.wikipedia.org/wiki/ISO_8601">wikipedia中的ISO-8601</a>），使用时间与日期部分（例如<code>2013-04-03T23:45Z</code>）。</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="restJsonBody">JSON body 参数</h5>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 4. JSON参数类型</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">类型</th>
<th class="tableblock halign-left valign-top">格式</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">纯文本参数。对于<code>XXXLike</code>参数，字符串可能会包含通配符<code>%</code>。可以进行like搜索。例如，'Tas%'将匹配所有以&#8217;Tas&#8217;开头的值。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Integer</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">整形参数，使用JSON数字。只能包含数字型非小数值，在-2.147.483.648至2.147.483.647之间。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Long</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">长整形参数，使用JSON数字。只能包含数字型非小数值，在-9.223.372.036.854.775.808至9.223.372.036.854.775.807之间。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Date</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">日期型参数，使用JSON文本。使用ISO-8601日期格式（参考<a href="http://en.wikipedia.org/wiki/ISO_8601">wikipedia中的ISO-8601</a>），使用时间与日期组分（例如<code>2013-04-03T23:45Z</code>）。</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="restPagingAndSort">分页与排序</h5>
<div class="paragraph">
<p>分页与排序参数可以作为查询字符串加入URL中（例如<code><a href="http://host/flowable-rest/service/deployments?sort=name" class="bare">http://host/flowable-rest/service/deployments?sort=name</a></code>中的name参数）。</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 5. JSON查询变量参数</caption>
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">参数</th>
<th class="tableblock halign-left valign-top">默认值</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">sort</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">各查询实现不同</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">排序键的名字，在各查询实现中默认值与可用值都不同。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">order</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">asc</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">排序顺序，可以是&#8217;asc'（顺序）或&#8217;desc'（逆序）。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">start</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">对结果分页的参数。默认结果从0开始。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">size</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">10</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">对结果分页的参数。默认大小为10.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="restQueryVariable">JSON查询变量格式</h5>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="json"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4
5
6
7</div></td><td class="code"><span></span>
<span class="tok-p">{</span>
  <span class="tok-nt">&quot;name&quot;</span> <span class="tok-p">:</span> <span class="tok-s2">&quot;variableName&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;value&quot;</span> <span class="tok-p">:</span> <span class="tok-s2">&quot;variableValue&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;operation&quot;</span> <span class="tok-p">:</span> <span class="tok-s2">&quot;equals&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;type&quot;</span> <span class="tok-p">:</span> <span class="tok-s2">&quot;string&quot;</span>
<span class="tok-p">}</span>
</td></tr></table></code></pre>
</div>
</div>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 6. JSON查询变量参数</caption>
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">参数</th>
<th class="tableblock halign-left valign-top">必填</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">name</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">否</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">包含在查询中的变量名。在有些使用'<code>equals</code>'的查询中可以为空，查询<strong>任意变量名</strong>为给定值的资源。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">value</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">是</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">包含在查询中的变量值，需要使用给定类型的正确格式。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">operator</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">是</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">查询使用的操作，可以为下列值：<code>equals, notEquals, equalsIgnoreCase, notEqualsIgnoreCase, lessThan, greaterThan, lessThanOrEquals, greaterThanOrEquals</code>与<code>like</code>。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">type</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">否</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">所用变量的类型。当省略时，会从<code>value</code>参数推理类型。任何JSON文本值都使用是<code>string</code>类型，JSON boolean值使用<code>boolean</code>类型，JSON数字使用<code>long</code>或<code>integer</code>，取决于数字的大小。建议在有疑惑时明确指定类型。其他支持的类型列在下面。</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 7. 默认查询JSON类型</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">类型名</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">值处理转换为<code>java.lang.String</code>。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">short</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">值处理转换为<code>java.lang.Integer</code>。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">值处理转换为<code>java.lang.Integer</code>。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">long</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">值处理转换为<code>java.lang.Long</code>。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">double</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">值处理转换为<code>java.lang.Double</code>。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">值处理转换为<code>java.lang.Boolean</code>。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">date</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">值处理转换为<code>java.util.Date</code>。JSON字符串将使用ISO-8601日期格式转换。</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="restVariables">变量表示</h5>
<div class="paragraph">
<p>读取与写入变量（执行选择）时，REST API都使用通用原则与JSON格式。变量的JSON表示为：</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="json"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4
5
6</div></td><td class="code"><span></span><span class="tok-p">{</span>
  <span class="tok-nt">&quot;name&quot;</span> <span class="tok-p">:</span> <span class="tok-s2">&quot;variableName&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;value&quot;</span> <span class="tok-p">:</span> <span class="tok-s2">&quot;variableValue&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;valueUrl&quot;</span> <span class="tok-p">:</span> <span class="tok-s2">&quot;http://...&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;type&quot;</span> <span class="tok-p">:</span> <span class="tok-s2">&quot;string&quot;</span>
<span class="tok-p">}</span>
</td></tr></table></code></pre>
</div>
</div>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 8. 变量的JSON属性</caption>
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">参数</th>
<th class="tableblock halign-left valign-top">必填</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">name</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">是</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">变量名。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">value</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">否</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">变量的值。当写入变量且省略了<code>value</code>时，会使用<code>null</code>作为value。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">valueUrl</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">否</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">当读取<code>binary</code>或<code>serializable</code>类型的变量时，这个属性将指向可用于获取原始二进制数据的URL。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">type</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">否</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">变量的类型。查看下面的表格了解类型的更多信息。当写入变量且省略了这个值时，将使用请求的原始JSON属性类型推断，限制在<code>string</code>, <code>double</code>, <code>integer</code>与<code>boolean</code>中。建议总是包含类型，以确保不会错误推断类型。</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 9. 变量类型</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">类型名</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">值按照<code>java.lang.String</code>处理。写入变量时使用原始JSON文本。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">值按照<code>java.lang.Integer</code>处理。按约定写入变量时使用JSON数字，失败则退回JSON文本。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">short</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">值按照<code>java.lang.Short</code>处理。按约定写入变量时使用JSON数字，失败则退回JSON文本。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">long</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">值按照<code>java.lang.Long</code>处理。按约定写入变量时使用JSON数字，失败则退回JSON文本。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">double</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">值按照<code>java.lang.Double</code>处理。按约定写入变量时使用JSON数字，失败则退回JSON文本。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">值按照<code>java.lang.Boolean</code>处理。按约定写入变量时使用JSON boolean。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">date</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">值按照<code>java.util.Date</code>处理。写入变量时将转换为ISO-8601日期格式。</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>可以使用自定义JSON表示，以支持额外的变量类型（既可以是简单值，也可以是复杂/嵌套的JSON对象）。通过扩展<code>org.flowable.rest.service.api.RestResponseFactory</code>的<code>initializeVariableConverters()</code>方法，可以添加额外的<code>org.flowable.rest.service.api.engine.variable.RestVariableConverter</code>类，用于将POJO转换为适合通过REST传输的格式，以及将REST值转换为POJO。实际转换JSON使用Jackson。</p>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_部署">7.2. 部署</h3>
<div class="paragraph">
<p><strong>当使用tomcat时，请阅读 <a href="#restUsageInTomcat">Usage in Tomcat</a>.</strong></p>
</div>
<div class="sect3">
<h4 id="_获取多个dmn部署">7.2.1. 获取多个DMN部署</h4>
<div class="listingblock">
<div class="content">
<pre>GET dmn-repository/deployments</pre>
</div>
</div>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 10. URL 查询参数</caption>
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">参数</th>
<th class="tableblock halign-left valign-top">必需</th>
<th class="tableblock halign-left valign-top">类型</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">name</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">返回指定名称的部署.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">nameLike</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">模糊查询指定名称.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">category</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">返回指定类别.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">categoryNotEquals</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">返回指定类别以外的部署.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">tenantId</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">返回指定tenantId的部署.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">tenantIdLike</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">模糊查询指定tenantId的部署.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">withoutTenantId</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">如果为true 则返回指定tenantId以外的部署，如果为false 则忽略掉该参数.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">sort</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>id</em> (default), <em>name</em>, <em>deploytime</em> or <em>tenantId</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">属性进行排序，与“order”一起使用.</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 11. REST 返回编码</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Response code</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">200</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Indicates the request was successful.</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">返回编码</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">200</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">请求成功.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p><strong>Success response body:</strong>
<strong>成功返回示例:</strong></p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="json"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18</div></td><td class="code"><span></span><span class="tok-p">{</span>
  <span class="tok-nt">&quot;data&quot;</span><span class="tok-p">:</span> <span class="tok-p">[</span>
    <span class="tok-p">{</span>
      <span class="tok-nt">&quot;id&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;03ab310d-c1de-11e6-a4f4-62ce84ef239e&quot;</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;name&quot;</span><span class="tok-p">:</span> <span class="tok-kc">null</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;deploymentTime&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;2016-12-14T10:16:37.000+01:00&quot;</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;category&quot;</span><span class="tok-p">:</span> <span class="tok-kc">null</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;url&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;http://localhost:8080/flowable-rest/dmn-api/dmn-repository/deployments/03ab310d-c1de-11e6-a4f4-62ce84ef239e&quot;</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;parentDeploymentId&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;17510&quot;</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;tenantId&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;&quot;</span>
    <span class="tok-p">}</span>
  <span class="tok-p">],</span>
  <span class="tok-nt">&quot;total&quot;</span><span class="tok-p">:</span> <span class="tok-mi">1</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;start&quot;</span><span class="tok-p">:</span> <span class="tok-mi">0</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;sort&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;id&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;order&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;asc&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;size&quot;</span><span class="tok-p">:</span> <span class="tok-mi">1</span>
<span class="tok-p">}</span>
</td></tr></table></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_获取一个dmn部署">7.2.2. 获取一个DMN部署</h4>
<div class="listingblock">
<div class="content">
<pre>GET dmn-repository/deployments/{deploymentId}</pre>
</div>
</div>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 12. 获取一个部署- URL 参数</caption>
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">参数</th>
<th class="tableblock halign-left valign-top">必需</th>
<th class="tableblock halign-left valign-top">类型</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">deploymentId</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">部署唯一id.</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 13. 获取一个部署- 返回编码</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">返回编码</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">200</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">找到并返回指定部署.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">404</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">为找到指定的部署.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p><strong>成功示例:</strong></p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="json"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4
5
6
7
8
9</div></td><td class="code"><span></span><span class="tok-p">{</span>
  <span class="tok-nt">&quot;id&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;03ab310d-c1de-11e6-a4f4-62ce84ef239e&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;name&quot;</span><span class="tok-p">:</span> <span class="tok-kc">null</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;deploymentTime&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;2016-12-14T10:16:37.000+01:00&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;category&quot;</span><span class="tok-p">:</span> <span class="tok-kc">null</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;url&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;http://localhost:8080/flowable-rest/dmn-api/dmn-repository/deployments/03ab310d-c1de-11e6-a4f4-62ce84ef239e&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;parentDeploymentId&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;17510&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;tenantId&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;&quot;</span>
<span class="tok-p">}</span>
</td></tr></table></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_create_a_new_dmn_deployment">7.2.3. Create a new DMN deployment</h4>
<div class="paragraph">
<p>（创建一个DMN部署）</p>
</div>
<div class="listingblock">
<div class="content">
<pre>POST dmn-repository/deployments</pre>
</div>
</div>
<div class="paragraph">
<p><strong>Request body:</strong>
<strong>请求消息体:</strong></p>
</div>
<div class="paragraph">
<p>The request body should contain data of type <em>multipart/form-data</em>. There should be exactly one file in the request: any additional files will be ignored. The deployment name is the name of the file-field passed in.
（请求消息体应该包含 <em>multipart/form-data</em> 类型。请求中应该只有一个文件:任何额外的文件都将被忽略。file-field 的名称作为部署的名称）
An additional parameter (form-field) can be passed in the request body with name <code>tenantId</code>. The value of this field will be used as the identifier of the tenant in which this deployment is done.
（可以在请求体中通过name +tenantId+传递附加参数(表单字段)。此字段的值将用作执行此部署的租户的标识符。）
.Create a new DMN deployment - Response codes
（创建一个DMN部署-返回编码）</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Response code</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">201</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Indicates the deployment was created.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">400</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Indicates there was no content present in the request body or the content mime-type is not supported for deployment. The status-description contains additional information.</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">返回编码</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">201</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">指定的部署已经存在.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">400</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">请求主体中不存在内容，或部署不支持该内容的mime-type。状态描述包含附加信息。</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p><strong>Success response body:</strong>
(<strong>成功示例:</strong>)</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="json"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4
5
6
7
8</div></td><td class="code"><span></span><span class="tok-p">{</span>
  <span class="tok-nt">&quot;id&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;03ab310d-c1de-11e6-a4f4-62ce84ef239e&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;name&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;newDeployment1&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;deploymentTime&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;2016-12-14T10:16:37.000+01:00&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;category&quot;</span><span class="tok-p">:</span> <span class="tok-kc">null</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;url&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;http://localhost:8080/flowable-rest/dmn-api/dmn-repository/deployments/03ab310d-c1de-11e6-a4f4-62ce84ef239e&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;tenantId&quot;</span> <span class="tok-p">:</span> <span class="tok-s2">&quot;myTenant&quot;</span>
<span class="tok-p">}</span>
</td></tr></table></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_delete_a_dmn_deployment">7.2.4. Delete a DMN deployment</h4>
<div class="paragraph">
<p>（删除一个部署）</p>
</div>
<div class="listingblock">
<div class="content">
<pre>DELETE dmn-repository/deployments/{deploymentId}</pre>
</div>
</div>
<div class="paragraph">
<div class="title">Delete a DMN deployment - URL parameters</div>
<p>（删除一个部署- URL 参数）</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Parameter</th>
<th class="tableblock halign-left valign-top">Required</th>
<th class="tableblock halign-left valign-top">Value</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">deploymentId</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The identifier of the deployment to delete.</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">参数</th>
<th class="tableblock halign-left valign-top">必需</th>
<th class="tableblock halign-left valign-top">类型</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">deploymentId</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">需要删除的部署的编号.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<div class="title">Delete a DMN deployment - Response codes</div>
<p>（删除一个部署 - 返回编码）</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Response code</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">204</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Indicates the deployment was found and has been deleted. Response-body is intentionally empty.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">404</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Indicates the requested deployment was not found.</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">返回编码</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">204</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">指定的部署已经被删除。返回内容特意为空。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">404</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">未找到指定的部署。</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect3">
<h4 id="_get_a_dmn_deployment_resource_content">7.2.5. Get a DMN deployment resource content</h4>
<div class="paragraph">
<p>（获取DMN部署资源内容）</p>
</div>
<div class="listingblock">
<div class="content">
<pre>GET dmn-repository/deployments/{deploymentId}/resourcedata/{resourceId}</pre>
</div>
</div>
<div class="paragraph">
<div class="title">Get a deployment resource content - URL parameters</div>
<p>（获取DMN部署资源内容 - URL 参数）</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Parameter</th>
<th class="tableblock halign-left valign-top">Required</th>
<th class="tableblock halign-left valign-top">Value</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">deploymentId</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The identifier of the deployment the requested resource is part of.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">resourceId</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The identifier of the resource to get the data for. <strong>Make sure you URL-encode the resourceId in case it contains forward slashes. For example, use <em>decisions%2Fmy-decision.dmn</em> instead of <em>decisions/my-decision.dmn</em>.</strong></p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">参数</th>
<th class="tableblock halign-left valign-top">必需</th>
<th class="tableblock halign-left valign-top">类型</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">deploymentId</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">指定部署编号。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">resourceId</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">指定资源编号。确保resourceId的URL编码，以防它包含前斜杠。例如，使用 <em>decisions%2Fmy-decision.dmn</em>。而不是&#8217;decisions/my-decision.dmn'</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<div class="title">Get a deployment resource content - Response codes</div>
<p>（.获取DMN部署资源内容 - 返回编码）</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Response code</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">200</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Indicates both deployment and resource have been found and the resource data has been returned.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">404</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Indicates the requested deployment was not found or there is no resource with the given identifier present in the deployment. The status-description contains additional information.</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Response code</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">200</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">已找到指定的部署和资源，并返回资源数据。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">404</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">未找到所请求的部署，或部署中不存在指定的资源。状态描述包含附加信息。</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p><strong>Success response body:</strong>
（<strong>成功示例:</strong>）</p>
</div>
<div class="paragraph">
<p>The response body will contain the binary resource-content for the requested resource. The response content-type will be the same as the type returned in the resources <em>mimeType</em> property. Also, a content-disposition header is set, allowing browsers to download the file instead of displaying it.
（响应体将包含请求资源的二进制资源内容。响应内容类型将与资源“mimeType”属性中返回的类型相同。此外，header还设置了一个content-disposition ，允许浏览器下载文件而不是显示它。）</p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_decision_tables">7.3. Decision Tables</h3>
<div class="paragraph">
<p>（决策表）</p>
</div>
<div class="sect3">
<h4 id="_list_of_decision_tables">7.3.1. List of decision tables</h4>
<div class="paragraph">
<p>（获取决策表列表）</p>
</div>
<div class="listingblock">
<div class="content">
<pre>GET dmn-repository/decision-tables</pre>
</div>
</div>
<div class="paragraph">
<div class="title">List of process definitions - URL parameters</div>
<p>（获取流程定义列表- URL 参数）</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Parameter</th>
<th class="tableblock halign-left valign-top">Required</th>
<th class="tableblock halign-left valign-top">Value</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">version</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Only return process definitions with the given version.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">name</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Only return process definitions with the given name.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">nameLike</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Only return process definitions with a name like the given name.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">key</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Only return process definitions with the given key.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">keyLike</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Only return process definitions with a name like the given key.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">resourceName</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Only return process definitions with the given resource name.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">resourceNameLike</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Only return process definitions with a name like the given resource name.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">category</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Only return process definitions with the given category.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">categoryLike</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Only return process definitions with a category like the given name.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">categoryNotEquals</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Only return process definitions which don&#8217;t have the given category.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">deploymentId</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Only return process definitions which are part of a deployment with the given identifier.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">latest</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Only return the latest process definition versions. Can only be used together with <em>key</em> and <em>keyLike</em> parameters, using any other parameter will result in a 400-response.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">sort</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>name</em> (default), <em>id</em>, <em>key</em>, <em>category</em>, <em>deploymentId</em> and <em>version</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Property to sort on, to be used together with the <em>order</em>.</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">参数</th>
<th class="tableblock halign-left valign-top">必需</th>
<th class="tableblock halign-left valign-top">类型</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">version</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">返回指定版本的流程定义。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">name</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">返回指定名称的流程定义。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">nameLike</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">模糊查询指定名称的流程定义。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">key</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">返回指定key的流程定义。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">keyLike</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">模糊查询指定key的流程定义。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">resourceName</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">返回指定资源名称的流程定义。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">resourceNameLike</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">模糊查询指定资源名称的流程定义。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">category</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">返回指定类别的流程定义。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">categoryLike</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">模糊查询指定名称的流程定义。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">categoryNotEquals</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">返回指定类型以外的流程定义。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">deploymentId</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">返回指定部署编号的流程定义。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">latest</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">返回最新版本的流程定义。只能与“key”和“keyLike”参数一起使用，使用任何其他参数都会得到400个响应。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">sort</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>name</em> (default), <em>id</em>, <em>key</em>, <em>category</em>, <em>deploymentId</em> and <em>version</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">排序，与“order”一起使用。</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 14. 获取流程定义列表 - 返回编码</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">返回编码</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">200</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">请求成功，并返回决策表</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">400</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">参数以错误的格式传递，或&#8217;latest' 与&#8217;key' 和 'keyLike&#8217;以外的其他参数一起使用。状态消息包含其他信息。</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p><strong>成功示例:</strong></p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="json"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22</div></td><td class="code"><span></span><span class="tok-p">{</span>
  <span class="tok-nt">&quot;data&quot;</span><span class="tok-p">:</span> <span class="tok-p">[</span>
        <span class="tok-p">{</span>
      <span class="tok-nt">&quot;id&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;46b0379c-c0a1-11e6-bc93-6ab56fad108a&quot;</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;url&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;http://localhost:8080/flowable-rest/dmn-api/dmn-repository/decision-tables/46b0379c-c0a1-11e6-bc93-6ab56fad108a&quot;</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;category&quot;</span><span class="tok-p">:</span> <span class="tok-kc">null</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;name&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;Decision Table One&quot;</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;key&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;DecisionTableOne&quot;</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;description&quot;</span><span class="tok-p">:</span> <span class="tok-kc">null</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;version&quot;</span><span class="tok-p">:</span> <span class="tok-mi">3</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;resourceName&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;dmn-DecisionTableOne.dmn&quot;</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;deploymentId&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;46aa6b3a-c0a1-11e6-bc93-6ab56fad108a&quot;</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;parentDeploymentId&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;5001&quot;</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;tenantId&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;&quot;</span>
    <span class="tok-p">}</span>
  <span class="tok-p">],</span>
  <span class="tok-nt">&quot;total&quot;</span><span class="tok-p">:</span> <span class="tok-mi">1</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;start&quot;</span><span class="tok-p">:</span> <span class="tok-mi">0</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;sort&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;name&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;order&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;asc&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;size&quot;</span><span class="tok-p">:</span> <span class="tok-mi">1</span>
<span class="tok-p">}</span>
</td></tr></table></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_获取一个决策表">7.3.2. 获取一个决策表</h4>
<div class="listingblock">
<div class="content">
<pre>GET dmn-repository/decision-tables/{decisionTableId}</pre>
</div>
</div>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 15. 获取一个决策表 - URL 参数</caption>
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">参数</th>
<th class="tableblock halign-left valign-top">必需</th>
<th class="tableblock halign-left valign-top">类型</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">decisionTableId</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">决策表编号。</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 16. 获取一个决策表 - 返回编码</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Response code</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">200</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">找到指定编号决策表并返回</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">404</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">未找到指定编号决策表</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p><strong>成功示例:</strong></p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="json"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13</div></td><td class="code"><span></span><span class="tok-p">{</span>
  <span class="tok-nt">&quot;id&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;46b0379c-c0a1-11e6-bc93-6ab56fad108a&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;url&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;http://localhost:8080/flowable-rest/dmn-api/dmn-repository/decision-tables/46b0379c-c0a1-11e6-bc93-6ab56fad108a&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;category&quot;</span><span class="tok-p">:</span> <span class="tok-kc">null</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;name&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;Decision Table One&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;key&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;DecisionTableOne&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;description&quot;</span><span class="tok-p">:</span> <span class="tok-kc">null</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;version&quot;</span><span class="tok-p">:</span> <span class="tok-mi">3</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;resourceName&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;dmn-DecisionTableOne.dmn&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;deploymentId&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;46aa6b3a-c0a1-11e6-bc93-6ab56fad108a&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;parentDeploymentId&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;5001&quot;</span><span class="tok-p">,</span>
  <span class="tok-nt">&quot;tenantId&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;&quot;</span>
<span class="tok-p">}</span>
</td></tr></table></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_获取一个决策表资源内容">7.3.3. 获取一个决策表资源内容</h4>
<div class="listingblock">
<div class="content">
<pre>GET dmn-repository/decision-tables/{decisionTableId}/resourcedata</pre>
</div>
</div>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 17. 获取一个决策表资源内容 - URL 参数</caption>
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">参数</th>
<th class="tableblock halign-left valign-top">必需</th>
<th class="tableblock halign-left valign-top">类型</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">decisionTableId</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">决策表编号。</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p><strong>返回:</strong></p>
</div>
<div class="paragraph">
<p>与 <code>GET dmn-repository/deployment/{deploymentId}/resourcedata/{resourceId}</code> 相同.</p>
</div>
</div>
<div class="sect3">
<h4 id="_获取一个决策表dmn模型">7.3.4. 获取一个决策表DMN模型</h4>
<div class="listingblock">
<div class="content">
<pre>GET dmn-repository/decision-tables/{decisionTableId}/model</pre>
</div>
</div>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 18. 获取一个决策表DMN模型- URL 参数</caption>
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">参数</th>
<th class="tableblock halign-left valign-top">必需</th>
<th class="tableblock halign-left valign-top">类型</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">decisionTableId</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">决策表编号。</p></td>
</tr>
</tbody>
</table>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 19. 获取一个决策表DMN模型- 返回编码</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">返回编码</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">200</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">找到指定决策表并返回模型。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">404</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">未找到指定决策表。</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p><strong>返回内容:</strong>
返回内容是+org.flowable.dmn.model.DmnDefinition+的JSON。并包含完整的DMN定义模型。</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="json"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15</div></td><td class="code"><span></span><span class="tok-p">{</span>
   <span class="tok-nt">&quot;processes&quot;</span><span class="tok-p">:[</span>
      <span class="tok-p">{</span>
         <span class="tok-nt">&quot;id&quot;</span><span class="tok-p">:</span><span class="tok-s2">&quot;oneTaskProcess&quot;</span><span class="tok-p">,</span>
         <span class="tok-nt">&quot;xmlRowNumber&quot;</span><span class="tok-p">:</span><span class="tok-mi">7</span><span class="tok-p">,</span>
         <span class="tok-nt">&quot;xmlColumnNumber&quot;</span><span class="tok-p">:</span><span class="tok-mi">60</span><span class="tok-p">,</span>
         <span class="tok-nt">&quot;extensionElements&quot;</span><span class="tok-p">:{</span>

         <span class="tok-p">},</span>
         <span class="tok-nt">&quot;name&quot;</span><span class="tok-p">:</span><span class="tok-s2">&quot;The One Task Process&quot;</span><span class="tok-p">,</span>
         <span class="tok-nt">&quot;executable&quot;</span><span class="tok-p">:</span><span class="tok-kc">true</span><span class="tok-p">,</span>
         <span class="tok-nt">&quot;documentation&quot;</span><span class="tok-p">:</span><span class="tok-s2">&quot;One task process description&quot;</span><span class="tok-p">,</span>

    <span class="tok-err">]</span>
<span class="tok-p">}</span>
</td></tr></table></code></pre>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_dmn规则服务">7.4. DMN规则服务</h3>
<div class="sect3">
<h4 id="_执行一个决策">7.4.1. 执行一个决策</h4>
<div class="listingblock">
<div class="content">
<pre>POST dmn-rule/execute</pre>
</div>
</div>
<div class="paragraph">
<p><strong>Request body:</strong></p>
</div>
<div class="paragraph">
<p>请求体应该包含_multipart/form-data_类型的数据。需要decisionKey。tenantId、parentdeploymentd和inputVariables (restVariables)映射是可选的。</p>
</div>
<div class="paragraph">
<p><strong>Response body:</strong></p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="json"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26</div></td><td class="code"><span></span><span class="tok-p">{</span>
  <span class="tok-nt">&quot;resultVariables&quot;</span><span class="tok-p">:</span> <span class="tok-p">[</span>
    <span class="tok-p">[</span>
      <span class="tok-p">{</span>
        <span class="tok-nt">&quot;name&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;output1&quot;</span><span class="tok-p">,</span>
        <span class="tok-nt">&quot;type&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;string&quot;</span><span class="tok-p">,</span>
        <span class="tok-nt">&quot;value&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;result 1&quot;</span>
      <span class="tok-p">}</span>
    <span class="tok-p">],</span>
    <span class="tok-p">[</span>
      <span class="tok-p">{</span>
        <span class="tok-nt">&quot;name&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;output1&quot;</span><span class="tok-p">,</span>
        <span class="tok-nt">&quot;type&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;string&quot;</span><span class="tok-p">,</span>
        <span class="tok-nt">&quot;value&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;result 2&quot;</span>
      <span class="tok-p">}</span>
    <span class="tok-p">],</span>
    <span class="tok-p">[</span>
      <span class="tok-p">{</span>
        <span class="tok-nt">&quot;name&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;output1&quot;</span><span class="tok-p">,</span>
        <span class="tok-nt">&quot;type&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;string&quot;</span><span class="tok-p">,</span>
        <span class="tok-nt">&quot;value&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;result 3&quot;</span>
      <span class="tok-p">}</span>
    <span class="tok-p">]</span>
  <span class="tok-p">],</span>
  <span class="tok-nt">&quot;url&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;http://localhost:8080/flowable-rest/dmn-api/dmn-rule/execute&quot;</span>
<span class="tok-p">}</span>
</td></tr></table></code></pre>
</div>
</div>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 20. 执行一个决策 - 返回编码</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">返回编码</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">201</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">已执行该决策。</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect3">
<h4 id="_执行一个单结果决策">7.4.2. 执行一个单结果决策</h4>
<div class="listingblock">
<div class="content">
<pre>POST dmn-rule/execute/single-result</pre>
</div>
</div>
<div class="paragraph">
<p><strong>Request body:</strong></p>
</div>
<div class="paragraph">
<p>请求体应该包含_multipart/form-data_类型的数据。需要decisionKey。tenantId、parentdeploymentd和inputVariables (restVariables)映射是可选的。</p>
</div>
<div class="paragraph">
<p>当多个规则有效时，返回500。</p>
</div>
<div class="paragraph">
<p><strong>注意:使用复合输出的单个命中是有效的(参见下面的响应)</strong></p>
</div>
<div class="paragraph">
<p><strong>Response body:</strong></p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="json"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15</div></td><td class="code"><span></span><span class="tok-p">{</span>
  <span class="tok-nt">&quot;resultVariables&quot;</span><span class="tok-p">:</span> <span class="tok-p">[</span>
    <span class="tok-p">{</span>
      <span class="tok-nt">&quot;name&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;output1&quot;</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;type&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;string&quot;</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;value&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;compound 1&quot;</span>
    <span class="tok-p">},</span>
    <span class="tok-p">{</span>
      <span class="tok-nt">&quot;name&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;output2&quot;</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;type&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;string&quot;</span><span class="tok-p">,</span>
      <span class="tok-nt">&quot;value&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;compound 2&quot;</span>
    <span class="tok-p">}</span>
  <span class="tok-p">],</span>
  <span class="tok-nt">&quot;url&quot;</span><span class="tok-p">:</span> <span class="tok-s2">&quot;http://localhost:8080/flowable-rest/dmn-api/dmn-rule/execute/single-result&quot;</span>
<span class="tok-p">}</span>
</td></tr></table></code></pre>
</div>
</div>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 21. 执行一个单结果决策 - 返回编码</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">返回编码</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">201</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">已执行指定决策。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">500</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">指定决策返回多个结果。</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect2">
<h3 id="_引擎">7.5. 引擎</h3>
<div class="sect3">
<h4 id="_获取一个dmn引擎信息">7.5.1. 获取一个DMN引擎信息</h4>
<div class="listingblock">
<div class="content">
<pre>GET dmn-management/engine</pre>
</div>
</div>
<div class="paragraph">
<p>返回此rest服务中使用的DMN引擎的只读视图。</p>
</div>
<div class="paragraph">
<p><strong>响应成功:</strong></p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="json"><table class="pyhltable"><tr><td class="linenos"><div class="linenodiv">1
2
3
4
5
6</div></td><td class="code"><span></span><span class="tok-p">{</span>
   <span class="tok-nt">&quot;name&quot;</span><span class="tok-p">:</span><span class="tok-s2">&quot;default&quot;</span><span class="tok-p">,</span>
   <span class="tok-nt">&quot;version&quot;</span><span class="tok-p">:</span><span class="tok-s2">&quot;6.4.2-SNAPSHOT&quot;</span><span class="tok-p">,</span>
   <span class="tok-nt">&quot;resourceUrl&quot;</span><span class="tok-p">:</span><span class="tok-s2">&quot;file://flowable-dmn/flowable.dmn.cfg.xml&quot;</span><span class="tok-p">,</span>
   <span class="tok-nt">&quot;exception&quot;</span><span class="tok-p">:</span><span class="tok-kc">null</span>
<span class="tok-p">}</span>
</td></tr></table></code></pre>
</div>
</div>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 22. 获取引擎信息 - 返回编码</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">返回编码</th>
<th class="tableblock halign-left valign-top">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">200</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">返回指定引擎信息。</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</body>
</html>